Is there a way of converting a char into a string in C?
I'm trying to do so like this:
char *array;
array[0] = '1';
int x = atoi(array);
printf("%d",x);
Is there a way of converting a char into a string in C?
I'm trying to do so like this:
char *array;
array[0] = '1';
int x = atoi(array);
printf("%d",x);
How about:
If you're trying to convert a numerical char to an int, just use character arithmetic to subtract the ASCII code:
You need to allocate memory to the string, and then null terminate.
Or, easier:
You can convert a character to a string via the following:
Strings end with a NUL character, which has the value 0.