Thread: MS VS and the infinite while loop

  1. #1
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102

    MS VS and the infinite while loop

    My friend was writing a very simple 32console app in visual C++ to count the number of a's in a sentence. He had a while loop in there but it kept getting stuck in the loop. After completely stripping down the program it looked something like this...
    PHP Code:
    #include <iostream>
    using namespace std;
    main()
    {
    int i=0;
    while(
    i<100)
    {
    i++;
    cout<<i;
    }
    return 
    0

    Nothing special. Added the cout to see what was up with the iterator...Hit execute and the console gives us this
    12222222222222222222222222222222222222222222222222 222222222222222... etc.
    It is a bug Microsoft is aware of and they give instructions on how to edit Visual studio to correct the bug(no patch?)
    It seems like a bug that could potentially cause some serious headaches for someone who might not know of the bug.
    WebSnozz-
    Cats have no butt cheeks.
    If one farted, then it would make a flute noise.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    It works just fine for me on MSVC++ 6 Enterprise. Btw, you forgot a semicolon after your return statement.
    Code:
    #include <iostream>
    using namespace std;
    
    main()
    {
        int i=0;
        while(i<100)
        {
            i++;
            cout<<i;
        }
        return 0;
    }
    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102
    It's not something that happens predictably. It's a seemingly random bug. To fix it on an occurence just delete the while loop and type it in again. I just thought I'd mention it since it's a particularly difficult thing to figure out when it does happen sinze it produces no syntax error message.
    WebSnozz-
    Cats have no butt cheeks.
    If one farted, then it would make a flute noise.

  4. #4
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    I had the same trouble in MSVC stuff would act crazy or not work right till i retyped or copied and pasted THE EXACT SAME CODE! thats one of many reaqsons i switched...
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

Popular pages Recent additions subscribe to a feed