I need to figure out how to append an int to a string, so basically i need to convert the int to a string 1st, but I cant figure out how. :rolleyes: any help would be greatly appreciated. thank you, courtney
cortiknee 0 Newbie Poster
Recommended Answers
Jump to PostGreetings,
This process is not hard since the default libraries included a function to do this. It's called itoa().
» char *itoa(int value, char *buffer, int radix);
Converts an integer value to a null-terminated string using the specified radix and stores the result in the given buffer.
If …
Jump to PostThis process is not hard since the default libraries included a function to do this. It's called itoa().
And itoa is nonstandard. A standard function is sprintf.
#include <stdio.h> int main(void) { const char base[] = "filename"; char filename [ FILENAME_MAX ]; int number = 42; sprintf(filename, …
Jump to Postsprintf(filename, "%s%d", base, number);
Ah, yes. Though remember sprintf() does not calculate for buffer overflow. sprintf() doesn't flush any file buffer, in fact it doesn't have any buffer associated with it. sprintf() operates on a character buffer (not quite the same thing). If you overflow that buffer …
Jump to Post» It's beyond me why people still use this.
Bitwise XOR Operator ^
a^b: 1 if both bits are different. 3 ^ 5 is 6.Yes, I think several of us know this swap trick. To others it may be confusing. It might even be
Jump to PostThree years later you repeat post #3. What would we do without your guidance?
All 21 Replies
Stack Overflow 8 Junior Poster
Dave Sinkula 2,398 long time no c Team Colleague
Stack Overflow 8 Junior Poster
Narue 5,707 Bad Cop Team Colleague
Stack Overflow 8 Junior Poster
Dave Sinkula 2,398 long time no c Team Colleague
Narue 5,707 Bad Cop Team Colleague
spincycle 0 Newbie Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Salem 5,265 Posting Sage
mcldev 0 Light Poster
Dave Sinkula 2,398 long time no c Team Colleague
dverex 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
dverex 0 Newbie Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
dverex 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
dverex 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.