Thread: *shakes head* I need help

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Code:
            	while ( i != 200 )
            	{
                      cout<< i <<endl;
                      i++;

    Code:
                 return 0;
    }
    }
    Change the while statement to while(1), which means the while loop is always true, and therefor going to repeat. Remove the cout, and i variable. Then add the ability to quit the program somehow (case or if statement), and all you do there is break; the loop.

    Also move the return 0; down under the end of the while loop, so it isn't just getting to the end of the while loop and exiting. So it should be between the two curly braces.

    Code:
            	char choice = 'n';
            	while (1)
            	{
                      cout<< "quit?" <<endl;
                      cin >> choice;
                      if(choice = 'y')
                                        break;
    Code:
    }
                 return 0;
    }
    BTW continue; is useful too. It will start the loop over again from the top, from where ever its encountered.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  2. #2
    Apprentice to Sly & Shane Inao's Avatar
    Join Date
    Nov 2005
    Location
    Oklahoma
    Posts
    32
    Oh ok, thank you much
    The Pristine Angel lives on!

Popular pages Recent additions subscribe to a feed