how to set string to null in c 1

how to set string to null in c

char *str;
/* ... allocate storage for str here ... */
*str = '\0'; /* Same as *str = 0; */

Here is what the above code is Doing:
1. Declare a pointer to a char called str.
2. Allocate storage for str.
3. Assign the value 0 to the memory location pointed to by str.

Similar Posts