Thread: hey guys

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    3

    hey guys

    im pretty new to c++

    im trying to run main funtion, but i cant figure out how to run the while statement as a case

    any ideas


    CASE A( Data == "Add")
    Add_City( list );

    CASE B( Data == "Clear")
    Delete_City ( list );

    CASE C( Data == "Output")
    View_City( list );

    CASE D( Data == "Update")
    Update_City( list );

    CASE E(Data == "Quit")
    cout << "Normal Termination of Counter Program";

    how can i make that compile?

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    i cant figure out how to run the while statement as a case
    While loops don't have cases. Look up a "switch statement" and use that format.

    edit: Scratch that. You are testing strings, so you can't use a switch statement, which requires you to be testing an integer value against other integer values. You will have to use a series of if-else if statements.
    how can i make that compile?
    No way, no how.
    Last edited by 7stud; 04-25-2005 at 11:15 AM.

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    3
    how do i do a switch statement?

  4. #4
    Registered User
    Join Date
    Oct 2004
    Posts
    32
    Your syntax is off. You want something like this:

    Code:
         switch(data)
          case Add: // assume that you have done an enum or a #define for Add
             Add_City( list );
              break;
          case Clear:  // same assumption ...
             Delete_City ( list );
              break;
          case Output: // ...
             View_City( list );
              break;
          case Update:
             Update_City( list );
              break;      
          case Quit:
             cout << "Normal Termination of Counter Program";
              break;
           default:
              cout << "Bad selection";

  5. #5
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Get yourself a good C++ book and start on page one. We can't teach you the whole language, dude.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Please read the forum guidelines:

    http://cboard.cprogramming.com/annou...ouncementid=51

    Pay extra attention to using descriptive subject titles, doing your part, and code tags.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hey guys, back again with a question
    By Velocity in forum C++ Programming
    Replies: 10
    Last Post: 10-19-2008, 02:27 PM
  2. Hey Guys! I Need Some Help Here!
    By Ruski in forum C++ Programming
    Replies: 6
    Last Post: 06-27-2002, 02:13 AM
  3. Hey Guys
    By D4050 in forum C Programming
    Replies: 0
    Last Post: 10-01-2001, 06:20 AM
  4. Tic Tac Toe -- Can you guys rate this please?
    By Estauns in forum Game Programming
    Replies: 2
    Last Post: 09-15-2001, 10:22 AM
  5. hello guys
    By lupi in forum C++ Programming
    Replies: 1
    Last Post: 09-09-2001, 01:00 AM