C++ Question

This is a discussion on C++ Question within the C++ Programming forums, part of the General Programming Boards category; The problem I have is how to do a switch where I have to call the certain choices. Code: int ...

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    16

    C++ Question

    The problem I have is how to do a switch where I have to call the certain choices.

    Code:
    int main(void)
    {
    do 
    {
    cout << "Hello there ." << endl;
    cout << "Select from the menu." << endl; 
    cout << "A gets lyrics." << endl; 
    cout << "B gets artist." << endl; 
    cout << "Q quits the program." << endl;
    cout << "Your choice: --> " << endl;
    cin >> user_choice; 
    
    switch (user_choice)
    {
    case 'A': lyrics 
    break; 
    case 'B': artists
    break; 
    }

  2. #2
    Not stupid, just stupider yaya's Avatar
    Join Date
    May 2007
    Location
    Earthland
    Posts
    204
    Everything looks fine except for the input. You haven't said what user_choice is (it should be a char). Then all you have to do is put what you want between "case 'A':" and "break;", etc.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,302
    So what's the question?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Registered User BuzzBuzz's Avatar
    Join Date
    Feb 2009
    Posts
    89
    Quote Originally Posted by Guru_ View Post
    how to do a switch where I have to call the certain choices.
    That would appear to be the question. Although there is no question mark, the use of the word "how" in the context of the overall statement infers an inherent query.
    Any help I give may be classified as:
    The Blind leading the Blind...
    Currently working through:
    "C++ Primer Plus"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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