Staredit Network

Staredit Network -> Computers and Technical -> Character string
Report, edit, etc...Posted by StarmanJr. on 2005-12-05 at 19:57:26
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.
Report, edit, etc...Posted by Pie_Sniper on 2005-12-06 at 01:11:27
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 = ""?
Next Page (1)