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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newb, string branching

Status
Not open for further replies.

ssmitty

Programmer
Sep 5, 2002
9
0
0
US
Hey im just learning the basics of c++, and I know how to use an if, for, or while statement to loop and branch my coding, but they can only work with integers. How can i get the same effects but usings char strings instead? Thanks in advance.
 
Simple. Use library function strcmp() from <cstring> or <string.h>

strcmp returns 0 when 2 strings match. so.....

if (strcmp(string1,string2)==0) cout<<&quot;Strings match&quot;;
else
cout<<&quot;Strings dont match&quot;;

im sure you get the idea.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top