varibles

This is a discussion on varibles within the C++ Programming forums, part of the General Programming Boards category; here is the code. PHP Code: #include <iostream>  #include <string>  using  namespace  std ;  int main ()      {                  string input ,  again ; ...

  1. #1
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608

    varibles

    here is the code.
    PHP Code:
    #include <iostream> 
    #include <string> 

    using namespace std

    int main()   
      {   
                 
    string inputagain;


       
    STARTcout << "  type a word... " << endl ;
              
    cin >> input;
        
              
    cout << "you typed " << input << output << endl ;
              
    Sleep(5000);
                               
    cout << endl ;
                               
    cout << endl ;
                               
    cout << endl ;

              
    cout << "would you like to exit or type another word? (another/exit)" << endl ;
                        
    cout << endl ;
              
    cin >> again;
      if(
    again == "another")
           goto 
    START;
      else if(
    again == "exit")
           goto 
    END;
        
    END:  cin.get();
      return 
    0;   
      } 
    the problem is if you want to type in another word the input varible does not change, neither does t he another varible. what should I do?
    Last edited by Klinerr1; 06-23-2002 at 05:57 PM.
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  2. #2
    Still A Registered User DISGUISED's Avatar
    Join Date
    Aug 2001
    Posts
    499
    Code:
    cout << "you typed " << input << output << endl ;
    I took out the "output" and it worked just fine for me.

  3. #3
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    hhmm stupid me. what i did when i posted was i took off my my original code and put in bassicly whta i thougt you all needed to knwo to answe rmy problem, even tho u didnt inform me with what i needed that output varible there lead me to fixinfg my program. thanks!
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  4. #4
    Unregistered
    Guest

    Angry

    omfg never used the accursed goto!

    fool! this isnt qb!

  5. #5
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    the command "goto" is also a very well used c++ command. wut would i use? i guess i could use loop. but i felt like goto. but in my case in the full program i havta use goto, cause the program at one point may skip to 1 of 10 lines. and goto is the only way.
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  6. #6
    Unregistered
    Guest

    Unhappy

    Ewww, goto is EVIL! NEVER, EVER use it!

  7. #7
    In The Light
    Join Date
    Oct 2001
    Posts
    598
    howdy,
    even Bjarne frowns on "goto" . i wonder why it was included in the language?

    M.R.
    I don't like you very much. Please post a lot less.
    Cheez
    *and then*
    No, I know you were joking. My point still stands.

  8. #8
    Unregistered
    Guest
    Originally posted by itld
    howdy,
    even Bjarne frowns on "goto" . i wonder why it was included in the language?

    M.R.
    it was included because of the fact that it can have some uses... like escaping deeply nested loops but goto should be avoided at all costs since they then to have bizarre effects on your code...

  9. #9
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    >>but goto should be avoided at all costs since they then to have bizarre effects on your code...

    ..not if you know what you want and know what you are doing with the GOTO.

    like in this case i dont think there are going to be some bizzare effect on the program.

    Though I agree that GOTOs should be avoided but they are not the huge evil that most of us make them to be.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with storing letters in varibles
    By cgsarebeast in forum C++ Programming
    Replies: 9
    Last Post: 05-09-2006, 07:03 PM
  2. problems storing values in varibles
    By stodd04 in forum C Programming
    Replies: 7
    Last Post: 02-08-2005, 11:56 AM
  3. Declaring Varibles
    By lbrault in forum C++ Programming
    Replies: 6
    Last Post: 02-05-2003, 12:23 PM
  4. extern varibles
    By manwhoonlyeats in forum C Programming
    Replies: 5
    Last Post: 12-18-2002, 12:43 AM
  5. C Functions and varibles
    By mart_man00 in forum C Programming
    Replies: 13
    Last Post: 08-01-2002, 02:11 PM

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