Skip to content

Instantly share code, notes, and snippets.

@wcypierre
Last active December 19, 2015 17:09
Show Gist options
  • Save wcypierre/5989184 to your computer and use it in GitHub Desktop.
Save wcypierre/5989184 to your computer and use it in GitHub Desktop.
[Howto] Empty a c-string
To empty the string(set strlen() to 0):
string[0] = '\0';
To empty the string till the first null character:
memset(string, 0, strlen(string));
To empty the string from the start till the end(for static array):
memset(string, 0, sizeof(string));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment