msvc++ 6.0 (illegal break?)

This is a discussion on msvc++ 6.0 (illegal break?) within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream.h> #include <stdlib.h> int main() { int tokens; int wheel1; int wheel2; int wheel3; char pull; rand(); while ...

  1. #1
    Unregistered
    Guest

    msvc++ 6.0 (illegal break?)

    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    int main()
    
    {
    	int tokens;
    	int wheel1;
    	int wheel2;
    	int wheel3;
    	char pull;
    	
    	rand();
    	
    	while (tokens>0);
    	{
    		cout<<"You have "<<tokens<<" tokens. Pull?";
    		cin>>pull;
    
    		if (pull != 'Y')
    		{
    			break;
    		}
    		
    		wheel1=((rand() % 3)+1);
    		wheel2=((rand() % 3)+1);
    		wheel3=((rand() % 3)+1);
    
    	}
    
    	return (0);
    }
    C:\Msvc++6.0\compile files\Text2.cpp(22) : error C2043: illegal break

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    while (tokens>0);

    Spot the unnecessary character.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    >> while(tokens>0);

    SHOULD BE

    >> while(tokens>0)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Looking for feedback on program segment
    By avron in forum C++ Programming
    Replies: 4
    Last Post: 05-07-2007, 04:38 PM
  3. SSH Hacker Activity!! AAHHH!!
    By Kleid-0 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 03-06-2005, 02:53 PM
  4. Keypress reading
    By geek@02 in forum Windows Programming
    Replies: 1
    Last Post: 06-16-2004, 12:16 PM
  5. A simple array question
    By frenchfry164 in forum C++ Programming
    Replies: 7
    Last Post: 11-25-2001, 03:13 PM

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