The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => The Orphanage => Topic started by: Robert Collins on November 03, 2005, 04:42:41 PM

Title: Clearing a string in C
Post by: Robert Collins on November 03, 2005, 04:42:41 PM
How do I clear a string in C?

A string in my C program contains data from a previous operation. Now I want to use that same string again for new data. I tried the following....

MyString[MAX_CHARS] = NULL;

....but the string still holds the previous data.
Title: Re: Clearing a string in C
Post by: hutch-- on November 03, 2005, 05:25:15 PM
Robert,

If its a zero terminated string buffer, just write an ascii zero to the first byte in the buffer.