+ 1
What is the difference between character array with and without null terminating character ?
9 Answers
+ 3
#include <stdio.h>
int main() {
char string[4] = {'a','b','c',0};
printf("%s\n",string);
char array[3] = {'a','b','c'};
int i;
for (i=0; i<3; ++i) {
printf("%c",array[i]);
}
return 0;
}
+ 3
a char array with a null terminating char could be safely used as a string...
while without it must be handled as an array, by knowing its length ^^
+ 1
Previously related thread, seems to be the root of the question ...
https://www.sololearn.com/Discuss/2794334/?ref=app
0
visph Can u please elaborate these two cases along with a sample code for both âŠ