Strings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim K

    Strings

    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,boo kType);

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

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


    Thanks,

    Tim


  • UmaGrama

    #2
    Re: Strings


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





    ïnt result = strcmp(Str1, Str2);


    --
    Posted via http://dbforums.com

    Comment

    Working...