hey guys

This is a discussion on hey guys within the C++ Programming forums, part of the General Programming Boards category; im pretty new to c++ im trying to run main funtion, but i cant figure out how to run the ...

  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,662
    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 12:15 PM.

  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
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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, 03:27 PM
  2. Hey Guys! I Need Some Help Here!
    By Ruski in forum C++ Programming
    Replies: 6
    Last Post: 06-27-2002, 03:13 AM
  3. Hey Guys
    By D4050 in forum C Programming
    Replies: 0
    Last Post: 10-01-2001, 07: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, 11:22 AM
  5. hello guys
    By lupi in forum C++ Programming
    Replies: 1
    Last Post: 09-09-2001, 02:00 AM

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