C++ code problem

Discussion in 'Computing, Science, and Technology' started by pody08, Jul 28, 2009.

  1. pody08

    pody08 Member

    Joined:
    Mar 3, 2008
    Messages:
    254
    Likes Received:
    0
    Device:
    iPhone 5 (Black)
    hi im only beginning to learn c++ and im just building a small guess the number game. i had the code successfully compiled but i wanted to add more so i added the brackets in. Now i get this error "fatal error C1075: end of file found before the left brace '{' " Could someone please tell me the solution to this problem.

    Code:
    #include "stdafx.h"
    #include <iostream>
    
    using namespace std ;
    
    int main()
    
    {
    	int thenumber = 76;
    
    	int playersguess;
    
    	cout << "Lets play guess my number! \n";
    	cout << "Type in a number between 1 and 100: ";
    
    	cin >> playersguess;
    	bool alive = true;
    
    	if (playersguess == thenumber)
    	{	
    		cout << "You got it!\n";
    	}
    	else
    	{	
    		if ( playersguess > thenumber )
    		{	
    			cout << "Lower!\n";
    		}		
    	    else 	
    			if ( playersguess < thenumber )
    			{	
    				cout << "Higher!\n";
    			}
    			else 
    				cout  << "This cannot happen!";
    char f;
    	cin >> f;
    		return 0;
    	} 
    
    Build Output:
    1>------ Build started: Project: Tutorial1, Configuration: Debug Win32 ------
    1>Compiling...
    1>Tutorial1.cpp
    1>c:\users\padraig\desktop\tutorial\tutorial1\tutorial1\tutorial1.cpp(40) : fatal error C1075: end of file found before the left brace '{' at 'c:\users\padraig\desktop\tutorial\tutorial1\tutorial1\tutorial1.cpp(8)' was matched
    1>Build log was saved at "file://c:\Users\Padraig\Desktop\Tutorial\Tutorial1\Tutorial1\Debug\BuildLog.htm"
    1>Tutorial1 - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    p.s if this is in the wrong section please move it.
  2. CHC

    CHC New Member

    Joined:
    Jan 15, 2009
    Messages:
    53
    Likes Received:
    0
    Device:
    2G iPod touch
    add a bracket to the end

Share This Page