c was not declared in this scope

This is a discussion on c was not declared in this scope within the C++ Programming forums, part of the General Programming Boards category; i am using eclipse and its telling me that c is not declared in this scope. Code: int main(){ hangman ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    12

    c was not declared in this scope

    i am using eclipse and its telling me that c is not declared in this scope.


    Code:
    int main(){
    	hangman hangmanrun;
    	do {
    		hangmanrun.hangmanclass();
    	    cout << "Play again? [y]es or [n]o" << flush;
    	    char c;
    	    cin >> c;
    	    } while ( c == 'y' || c == 'Y' );
    	return 0;
    }
    Last edited by altf4thc; 02-15-2010 at 01:39 PM. Reason: forgot to add what program im using

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,848
    The scope of c ends at the closing brace.

    Move char c; before the loop
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    12
    Thank you so much. sorry for the stupid question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xy was not declared in this scope: compiler error!
    By twilight in forum C++ Programming
    Replies: 41
    Last Post: 08-13-2009, 01:33 PM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  5. Nested loop frustration
    By caroundw5h in forum C Programming
    Replies: 14
    Last Post: 03-15-2004, 09:45 PM

Tags for this Thread


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