Last active
December 19, 2015 17:09
-
-
Save wcypierre/5989184 to your computer and use it in GitHub Desktop.
[Howto] Empty a c-string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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