Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Char Comparison and Update

Status
Not open for further replies.

queenie680

Programmer
Apr 16, 2002
4
US
I'm a beginner at C++, but I am writing a program that has an Char array of names like this char[3][16] = {"Stevens,Cory", "Smith,Will", "Cool,Joe"} I wanted my program to search for a name like this:

char name[16];
cout << &quot;Search for a name&quot; << endl;
cin >> name;
//loop statement
if (char[count] = name) //this is where I have the problem the names don't match for some reason can anyone help?
{
//update statement
}


Also when I update the name i wrote this:
char[count] = newName; //this gives my an error too. can anyone help on this?

I would really appreciate any help. Thanks!!!!
 
you need to use strcmp and strncpy when using char*. If you change to CString, the above will work fine

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top