Initialize a string in C to empty string


I want to initialize string in C to empty string. I tried:

string[0] = ""; 

but it wrote

"warning: assignment makes integer from pointer without a cast"

How should I do it then?


Answers:


Assuming your array called 'string' already exists, try

string[0] = '\0';

\0 is the explicit NUL terminator, required to mark the end of string.