I'm trying to clear the values in a character string in C++. For example:
char name[20];
cout << "Enter name: ";
cin >> name;
Now I want 'name' to have a NULL value. I could just place '\0' at the beginning of the string, but it still leaves the other spaces in the char array with values. Can someone please help me with this? I'd really appreciate it.
If you're on Windows you could just include windows.h and use ZeroMemory( name, 20 ); or, since you're using C++, why not use a string instead of a character array and use name = ""?