Any help?

This is a discussion on Any help? within the C++ Programming forums, part of the General Programming Boards category; [CODE} #include <iostream> using std::cout; using std::cin; int main() { unsigned short yes(int value); cout << "Am I sexy?\n"; cin ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    241

    Any help?

    [CODE}
    #include <iostream>

    using std::cout;
    using std::cin;

    int main()
    {
    unsigned short yes(int value);
    cout << "Am I sexy?\n";
    cin >>yes(int value);
    yes=1;
    no=0;
    if (int value=0) {
    cout << "Ouch, you cut me deep.\n";
    }
    else if (int value=1) {
    cout << "Oh, baby.\n";
    }
    cin.get()
    }
    [/CODE]
    its saying something about the cin... this is just a little messing around program because im jst starting out...

  2. #2
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Well if you're open to new ways of doing that, this is the way I would do it:
    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
    char ans[256];
    cout<<"Am I sexy?\n";
    cin>>ans;
    cin.ignore();
    if (strcmp(ans,"no")==0||strcmp(ans,"No")==0)
    cout << "Ouch, you cut me deep.\n";
    else if (strcmp(ans,"yes")==0||strcmp(ans,"Yes")==0)
    cout << "Oh, baby.\n";
    else
    cout<<"Huh?\n";
    
    cin.get();
    return 0;
    }
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    241
    thanks i got it to work now :-D i like that huh thing at the end of it

  4. #4
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Lol, no problem.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    241
    how would i make it loop back to the question if like they dont answer or just answer randomly?

  6. #6
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    how would i make it loop back to the question if like they dont answer or just answer randomly?
    http://www.cprogramming.com/tutorial/lesson3.html

  7. #7
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,802
    <string> is the header for the string container class, <cstring> is the one for the C-style character array related functions such as strcmp and such.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21