Thread: Error I cannot fix

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688

    Error I cannot fix

    Hey guys

    I have written this really simple program and when I compile using VC++ 8.0 express I get 2 errors I cannot fix as they apply to a header file within the compiler's own directory.

    Here is the source I have written:

    Code:
    #include <iostream>
    
    // function prototype
    int qualityPoints ( int );
    
    // main function - driver 
    //
    int main ( void ) {
    	int value = 0;
    
    	std::cout << "Enter value to pass range of 1 to 100 ( enter -1 "
    		<< "to quit ): ";
    	std::cin >> value;
    
    	while ( value != -1 ) {
    		if (( value < 1 ) || ( value >= 101 )) {
    			std::cout << "\nIgnoring value - out of range!\n\n";
    		}
    
    		std::cout << "Value returned was: " << qualityPoints( value )
    			<< std::endl;
    	}
    
    	std::cin.get();
    	std::cin.ignore();
    
    	return 0;
    }
    
    // function to return a value pending on the value passed
    int qualityPoints ( int x ) {
    	int point = 0;
    
    	if (( x >= 90 ) && ( x <= 100 )) {
    		point = 4;
    	}
    
    	else if (( x >= 80 ) && ( x <= 89 )) {
    		point = 3;
    	}
    
    	else if (( x >= 70 ) && ( x <= 79 )) {
    		point = 2;
    	}
    
    	else if (( x >= 60 ) && ( x <= 69 )) {
    		point = 1;
    	}
    
    	else {
    		point = 0;
    	}
    
    	return point;
    }
    Here are the errors:

    Code:
     error C2144: syntax error : '__w64 unsigned int' should be preceded by ';'
    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    The header file it opens is "sourceannations.h" when I click the error message to see which line it is refering too. How can I fix this error? I thought at first the IDE had crashed so I dumped the poject and re-did it, but no same errors again. Then I re-compiled an older program and it worked ok.

    im lost here. I appriciate any advice.
    Double Helix STL

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Compiles fine here, except it contains an infinite loop.

    How is "sourceannations.h" in any way related to this file? Remove it from the project if it is there?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    65
    You can get rid of the infinite loop if you make cin the logic test for the while:
    Code:
    int main ( ) 
    {
        int value = 0;
    
        std::cout << "Enter value to pass range of 1 to 100 ( enter -1 "
            << "to quit ): ";
    
        while ( std::cin >> value ) 
        {
            if ( value == -1)
            {
                exit(1);
            }
            else if (( value < 1 ) || ( value >= 101 )) 
            {
                std::cout << "\nIgnoring value - out of range!\n\n";
            }
    
            std::cout << "Value returned was: " << qualityPoints( value )
                << std::endl;
        }
    
        return 0;
    }
    I also didn't have a problem compiling.

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Hey guys thanks for the replys.

    I managed to solve it by deleting it from the directory dumping it from the project list after that. I re-wrote the program slower with working code and compiled it a few times, each time I had no problems.

    anon I think you are right, I must of somhow hit a shortcut key on keyboard when typing which included it But its all ok now
    Double Helix STL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 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, 08:18 PM
  2. compiling my code, i can't fix error
    By howru in forum C Programming
    Replies: 2
    Last Post: 04-22-2008, 03:38 AM
  3. Drag and Drop code (please help me fix)
    By John_L in forum C# Programming
    Replies: 1
    Last Post: 11-17-2007, 06:11 PM
  4. C++ code need help to fix
    By McReal in forum C++ Programming
    Replies: 9
    Last Post: 05-12-2007, 02:48 PM
  5. Help me fix my mess!!!!
    By Starr in forum C++ Programming
    Replies: 35
    Last Post: 02-01-2006, 03:40 PM