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 Rhinorhino 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
Joined
Sep 5, 2002
Messages
9
Location
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.

Similar threads

Replies
0
Views
293
Replies
15
Views
896
Replies
4
Views
427

Part and Inventory Search

Sponsor

Back
Top