char ups[] = "ups, ups, ups"; ups[0] = '\0';
To read a string empty? Or do you need to clear everything?
memset(ups, 0, sizeof(ups));
char ups[] = "ups, ups, ups"; ups[0] = '\0';
To read a string empty? Or do you need to clear everything?
memset(ups, 0, sizeof(ups));
After zeroing, this pointer will point to a zero-length string. Ie, yes, enough.
But you need to understand that the memory is not free.
On the other hand, if we make an array of lines as char [], then it is convenient to separate lines with the character '0', and use '00' as the flag of the end of the array. Therefore, it all depends on the implementation. In addition, if we write this array to a file, then we need to clearly define the volume that will be written. At least with fwrite functions.
For standard string functions, yes, zeroing the first element will suffice.
Source: https://ru.stackoverflow.com/questions/11609/