By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,586 Members | 1,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,586 IT Pros & Developers. It's quick & easy.

Strings

P: n/a
ok I want to compare a string based on the input

so lets say I have

string bookType = "";

cout << "Enter type of book:(enter either paperback or hardback):";
getline(cin,bookType);

//what is the best way to do the following:

if bookType = "paperback"
cout << "you chose paperback"
else
cout << "you chose hardback"
Thanks,

Tim
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

You can always use to compare two strings. Make sure to include string.h

īnt result = strcmp(Str1, Str2);
--
Posted via http://dbforums.com
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.