Thread: infinite loop

  1. #1
    Registered User
    Join Date
    Apr 2005

    infinite loop

    my program enter an infinite loop if the user inputs invalid data?

    I check the FAQ section and I got this code, I say super I fix my problem, but when I try to run my program I get 3 errors:

    	int a = 0;
    	while (cout << "Please Enter the Number of Clases Compleated: " && !(cin >> a))
    		 cout << "\nInvalid input" <<endl;
    		 cin.ignore(std::numeric_limits <int>::max(), '\n');
    	cout << "\n";
    	if (a < 2)
    		info[j].clas[0] = 'C';
    	else if (a>=2 && a<=4)
    		info[j].clas[0] = 'B';
    	else if (a>4)
    		info[j].clas[0] = 'A';
    	info[j].clas[1] = '\0';
    -not enough actual parameters for macro 'max'
    -error C2589: '(' : illegal token on right side of '::'
    -error C2143: syntax error : missing ')' before '::'
    -error C2059: syntax error : ')'

    Please help, the project is due next week. everything work but this section.

  2. #2
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Please relocate this thread to the c++ board.

    thank you.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe - Developing free software for the community.

  3. #3
    Registered User
    Join Date
    Oct 2001
    It looks good to me, but you may need to include limits:
    #include <limits>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 06-14-2009, 11:24 PM
  2. Cosine fucntion and infinite loop.
    By youareafever in forum C Programming
    Replies: 2
    Last Post: 11-07-2008, 04:45 AM
  3. Infinite Loop with GetAsyncKeyState
    By guitarist809 in forum Windows Programming
    Replies: 1
    Last Post: 04-18-2008, 12:09 PM
  4. Switch statement = infinite loop
    By Lucid003 in forum C++ Programming
    Replies: 10
    Last Post: 10-10-2005, 12:46 AM
  5. stays in loop, but it's not an infinite loop (C++)
    By Berticus in forum C++ Programming
    Replies: 8
    Last Post: 07-19-2005, 11:17 AM