I need to convert a char array to string.
Something like this:
char array[20];
char string[100];
array[0]='1';
array[1]='7';
array[2]='8';
array[3]='.';
array[4]='9';
...
I would like to get something like that:
char string[0]= array // where it was stored 178.9 ....in position [0]
You’re saying you have this:
And you’d like to have this:
You can’t have that. A char holds 1 character. That’s it.
A “string” in C is an array of characters followed by a sentinel character (NULL terminator).
Now if you want to copy the first x characters out of
arraytostringyou can do that withmemcpy():