What is the difference between initialising character array as this
char c[10]={0};
and this
char c[10]="";
char c[10]={0}; guarantees that every element of the array is 0. Note that in C++ you can write char c[10]={}; which has the same effect.
char c[10]=""; guarantees that only the first element of the array is 0; the other elements are uninitialised.
for (int i=0;i<10;i++){ if(c[i]=='\0') printf("null char"); printf("%c\n",c[i]); } when I print this way both give same outputchar data: you don't know what you're going to get.
std::stringfor strings if possible. AndNULLhas a different meaning than0