“+=” on a pointer changes the value of the pointer, it does not manipulate any data. Note that ' ' is the space character, but that " " is the nul-terminated string [array of char] consisting of a space (and the nul-terminator '\0').
To concatenate C-style strings you can use strcat().
You are not allocating any memory for someString. I suggest char someString[100] = ""; To add a char & a space to a string I suggest
// index 0 is the 1st char, index 1 is the 2nd char of the string someString[ strlen(someString)+2 ] = '\0'; // the NUL character someString[ strlen(someString)+1 ] = ' '; someString[ strlen(someString) ] = (char)data;
Is data really an int? If so then I suggest you sprintf() to convert the int to an ascii rep thereof.
Also note that your string must remain nul-terminated. My 1st example does that, and sprintf obeys the nul-termination convention. sprintf uses a lot of memory.
Ah, you’ve implemented the 1st solution additionally. The three lines with strlen in them are not needed if you use sprintf(). You just need the sprintf() line. Indeed, the last line ought to make it buggy because the sprintf() has lengthened the string! In my 1st non-sprintf() soln the nul-termination doesn’t get replaced until the last step. In short: Either use the three lines with strlen in them or use the sprintf.