Hello,
I'm writting program and need to convert int ot char array without \0 simbol. I have tryed snprintf , but his returns array full of \0 simbols if it is initilized elsware return full of garbidge. Is there any elegent way to aceave this?
What I'm trying to aceave is liek this:
1 2 3 4 5 6
char buffer[10];
int temp = 1231423;
// Do conversation...
// After conversation char array should look like this
// 1 2 3 1 4 2 3 _ _ _
// without \0 simbol
Everything in the standard library is either going to be a std::string... or is going to have/require a null terminator (the \0 character).
What you can do... is just overwrite the null with whatever you want afterwards:
1 2 3 4 5 6
sprintf(buffer, "%d", temp);
int len = strlen(buffer);
for(int x = len; x < 10; ++x)
buffer[x] = '_'; // replace null (and everything after it in the buffer)
// with an underscore. Or whatever other character you want.