Thread: Flooded :(

  1. #1
    Ice_Black
    Guest

    Exclamation Flooded :(

    int main()
    {
    again:
    char test[256];
    cout <<"Please enter a word: ";
    cin.get(test,256);
    cout <<"you said" <<test;
    goto again;
    getch();
    return 0;
    }


    It keep getting flooded once I enter a word, what would i expected is wait for keep press [cin.get()] again every time its loop.

    for example:

    1.
    Please enter a word: girls
    you said girls

    2.
    Please enter a word: love
    you said love

    3.
    Please enter a word: sex
    you said sex

    and so on by loop.

  2. #2
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    your telling it to goto again before getch ever executes

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Yep, like RoD said, its in an endless loop

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    ::bashes Ice_Black with large stick label "GOTO IS EVIL"::

  5. #5
    Ice_Black
    Guest
    Originally posted by RoD
    your telling it to goto again before getch ever executes
    well ignore getch,
    I want it loop again so I can type a word again.

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by -KEN-
    ::bashes Ice_Black with large stick label "GOTO IS EVIL"::
    Yea, you're right, odd i din't said that, must be getting soft.....

  7. #7
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    i was going to but noone ever told me why its bad.

    cout<<"Enter number of times u want me to run";
    cin>>numof

    for (int i; i <=numof; i++)
    {

    your code
    }

  8. #8
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by RoD
    i was going to but noone ever told me why its bad.
    Using GOTO's in your program creates spaghetti code, i jumps
    all over the program. Very ugly,slow and bad.

  9. #9
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    ahh, thnx for the explanation.

  10. #10
    Ice_Black
    Guest

    You not getting my point.

    Well I use for-loop this time haha.

    int main()
    {
    char test[256];
    for (int i = 1; i <=6; i++)
    {
    cout <<"Please enter your name: ";
    cin.get(test,256);
    cout <<"you said" <<test;
    }
    return 0;
    }

    it still flooding me without waiting for me to type a word.

    Once I typed: hello
    then it return stupid output (it didnt ask me to enter a word on second loop and so on [cin.get fail on fail if looping])

    Please enter your name: Hello
    you saidHelloPlease enter your name: you saidPlease enter your name: you saidPle
    ase enter your name: you saidPlease enter your name: you saidPlease enter your n
    ame: you said

  11. #11
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Try emptying test before every input, and replace

    Code:
     cout <<"you said" <<test;
    with

    Code:
     cout <<"you said" <<test << endl;

  12. #12
    Ice_Black
    Guest
    Originally posted by Travis Dane
    Try emptying test before every input, and replace

    Code:
     cout <<"you said" <<test;
    with

    Code:
     cout <<"you said" <<test << endl;
    Yeh I know, but like again it didnt ask me to enter a word again on second time loop cin.get(test,256);

  13. #13
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by Travis Dane
    Using GOTO's in your program creates spaghetti code, i jumps
    all over the program. Very ugly,slow and bad.
    Actually it's not slow. The opposite in fact.
    I agree that it is obsolete though .
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  14. #14
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by Magos
    Actually it's not slow. The opposite in fact.
    SHUSH! you're incouriging them!,hehe.
    Faster eh? Well that doesn't stack up against the
    inefficience, garbage layout, unreadable code.

  15. #15
    Ice_Black
    Guest
    Please some one help me out.

    The problem is while it is looping - it ignore the cin.get()
    I want something i can type a word again again and again (looping)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tales of a Flooded World - Freeware
    By Corky12190 in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 06-24-2006, 11:19 PM