Thread: compile problem

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    7

    Wink compile problem

    I have a problem compiling this program.Any suggestions is due tomorow.THANKS
    Code:
    #include <iostream.h>
    #define	MEAN = 65.4f
    #define	STD_DEV = 15.6f
    
    int main(void)
    {
    	float std_score;
    	int score;
        char grade;
    
    	cout <<"Enter the score of a student or enter -1 to stop: \n";
    	cin >> score;
    
    	while (score != -1)  
    	{
            std_score = (score - MEAN) / STD_DEV;
    
            if (std_score >= 1)
    			grade = ‘A’;
            else if (std_score >= 0)
    			grade = ‘B’;
    		else if (std_score >= -1)
    			grade = ‘C’;
    		else if (std_score >= -2)
    			grade = ‘D’;
    		else
    			grade = ‘F’;
    
    		cout << "Grade = " << grade endl;
    		cout << " Enter the next score or enter -1 to stop ";
    		cin >> score;
    }
    	return 0;
    }
    Cpp(17) : error C2059: syntax error : '='
    Cpp(20) : error C2018: unknown character '0x91'
    Cpp(20) : error C2018: unknown character '0x92'
    Cpp(20) : error C2065: 'A' : undeclared identifierCpp(22) : error C2018: unknown character '0x91'
    Cpp(22) : error C2018: unknown character '0x92'
    Cpp(22) : error C2065: 'B' : undeclared identifier
    Cpp(24) : error C2018: unknown character '0x91'
    Cpp(24) : error C2018: unknown character '0x92'
    Cpp(24) : error C2065: 'C' : undeclared identifier
    Cpp(26) : error C2018: unknown character '0x91'
    Cpp(26) : error C2018: unknown character '0x92'
    Cpp(26) : error C2065: 'D' : undeclared identifier
    Cpp(28) : error C2018: unknown character '0x91'
    Cpp(28) : error C2018: unknown character '0x92'
    Cpp(28) : error C2065: 'F' : undeclared identifier
    Cpp(30) : error C2146: syntax error : missing ';' before identifier 'endl'
    Cpp(30) : warning C4551: function call missing argument list
    Error executing cl.exe.

    .exe - 17 error(s), 1 warning(s)

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    Code:
    #define	MEAN = 65.4f
    #define	STD_DEV = 15.6f
    should be
    Code:
    #define	MEAN  65.4f
    #define	STD_DEV  15.6f
    and I'm not sure what this is:

    Code:
    ‘A’
    You seem to be using some weird character format.....Just use the normal apostraphe: '


    Code:
    cout << "Grade = " << grade endl;
    You need one more << in there. I'll let you figure out where.

  3. #3
    Registered User
    Join Date
    Nov 2004
    Posts
    7
    yes you right after "grade", thanks for the help.
    Have a nice night

  4. #4
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Just a quick thought: This is one of the reasons why programmers tend to prefer constants (in this case) to macros. (Not saying macros are 'evil' or what not, but there is something to be said for easier debugging )

    Cheers
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  5. #5
    Registered User
    Join Date
    Oct 2004
    Posts
    63
    I'm still a newb, so I shouldn't nitpick..but...

    #include <iostream.h>
    should be
    #include <iostream>
    instead.

    iostream.h is outdated.

  6. #6
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    No.. iostream.h is NOT outdated, at least not mine... it simply doesn't comply with the standard. Standard states iostream and use std namespaces.

  7. #7
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    No reason not to go with the standard.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  8. #8
    Coding Standard Rule 17.1: Use Standard C++ Library headers defined by the language standard and not outdated .h headers. For example, use <iostream> and not <iostream.h>, <cstdio> and not <stdio.h>.

    Side Note: ISO C++ defines the standard implemention of library components. Programmers should use these versions of the library rather than vendor-specific or C library versions.

    The use of iostream.h is outdated and its presence is preserved for backward-compatibility. As of 1996, people use <iostream>, which just #includes iostream.h on many platforms, anyway. Using <iostream> will ensure that all the right definitions are defined, declarations are declared, includes are included, etc.

    For further info, check out this link.


    - Stack Overflow
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 09-14-2008, 02:35 PM
  2. compile problem
    By chintugavali in forum C++ Programming
    Replies: 3
    Last Post: 02-21-2008, 12:16 AM
  3. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  4. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  5. size of Object c++ compile problem
    By micha_mondeli in forum C++ Programming
    Replies: 5
    Last Post: 04-06-2005, 01:20 PM