How can I fix these Error Messages (code below) 
Author Message
 How can I fix these Error Messages (code below)

Error   : undefined identifier 'toupper'
C_assign_4.c line 64   while(toupper(response) == 'Y')

Error   : ';' expected
C_assign_4.c line 67   inputdata empp;

Error   : undefined identifier 'outputdata'
C_assign_4.c line 70   outputdata emp[i];
Error   : ';' expected
C_assign_4.c line 76   }

Error   : expression syntax error
C_assign_4.c line 78   }

Error   : illegal function definition
C_assign_4.c line 81   void inputdata(structure employee *empp)

Warning : implicit 'int' is no longer supported in C++
C_assign_4.c line 83   fflush(stdin);

Error   : declaration syntax error
C_assign_4.c line 83   (&__files[0])

Warning : implicit 'int' is no longer supported in C++
C_assign_4.c line 84   printf("%s", stbl[9]);

Error   : declaration syntax error
C_assign_4.c line 84   printf("%s", stbl[9]);

Error   : declaration syntax error
C_assign_4.c line 85   gets(emp.fname);

Error   : ambiguous access to name found 'printf' and 'std::printf'
C_assign_4.c line 87   printf("%s", stbl[10]);

Error   : ambiguous access to name found 'gets' and 'std::gets'
C_assign_4.c line 88   gets(emp.lname);

//Include files
//#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//Macros
#define sl printf("\n");
#define dl printf("\n\n");

//Structure declaration
struct employee
{
        char fname[10];
        char lname[10];
        int emp_no;
        char dept[15];
        float hr_rate;
        int wk_hrs;

Quote:
};

//Prototypes
void outputfunc();
void inputdata();

//Global variables
struct employee emp[20]={0};
struct employee *empp;

//String tableture
char *stbl[]=   // is it pointer or not?
{
        "\n          IDNET EMPLOYEE DATABASE       ",//0
        "          ***********************      ",//1
        "          RECORD:                                         ",//2
        "          FIRST NAME:                                     ",//3
        "          LAST NAME:                                      ",//4
        "          EMPLOYEE NUMBER:                                ",//5
        "          DEPARTMENT:                                     ",//6
        "          HOURLY RATE:                                    ",//7
        "          WEEKLY HOURS:                           ",//8
        "     Enter employees first name:          ",//9
        "     Enter employees last name:           ",//10
        "     Enter employee number:                       ",//11
        "     Enter department:                                    ",//12
        "     Enter hourly rate:                           ",//13
        "     Enter weekly hours:                          ",//14
        "     Do you want to enter a new record?" //15

Quote:
};

int main(void)

{       int i=0 , j;
        float salary;
        char response;

        printf("%s", stbl[0]); sl;
        printf("%s", stbl[1]); dl; dl;
        printf("%s", stbl[15]); dl; dl;

        response = getchar();

        while(toupper(response) == 'Y')
        {
                empp = &emp[i];
                inputdata empp;//Function call  

                emp[i] = *empp;
                outputdata emp[i];//Function call

                printf("%s", stbl[15]);
                response = getchar();

                i++
        }
                for(j=0 ; j<i; j++)

Quote:
}

//Header function for user input
void inputdata(structure employee *empp)

        fflush(stdin);
        printf("%s", stbl[9]);
        gets(emp.fname);

        printf("%s", stbl[10]);
        gets(emp.lname);

        printf("%s", stbl[11]);
        gets(emp.emp_no);

        printf("%s", stbl[12]);
        gets(emp.dept);

        printf("%s", stbl[13]);
        gets(emp.hr_rate);

        printf("%s", stbl[14]);
        gets(emp.wk_hrs);



Tue, 04 Sep 2001 03:00:00 GMT  
 How can I fix these Error Messages (code below)


Quote:
> Error   : undefined identifier 'toupper'
> C_assign_4.c line 64   while(toupper(response) == 'Y')

You need a function prototype for toupper(). Include <ctype.h>

Quote:

> Error   : ';' expected
> C_assign_4.c line 67   inputdata empp;

Your code says this is a function call. It's nothing of the kind. To turn
it into a function call, you need to use the correct syntax.
inputdata(empp);

Quote:

> Error   : undefined identifier 'outputdata'
> C_assign_4.c line 70   outputdata emp[i];

See above.

Any further error messages from the compiler are likely to be affected by
the previous errors in the code, so there's no point continuing.

Quote:

> //Include files

// is illegal syntax in C.

Quote:
> //#include <conio.h>

conio.h is a non-standard header. So its contents are platform- and
implementation-dependent.

Quote:
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>

> //Macros
> #define sl printf("\n");
> #define dl printf("\n\n");

Now is not the time to obfuscate your code. Keep your code simple, don't
complicate it by putting in useless macros, when your knowledge of syntax
is not strong enough to support such use.

Quote:

> //Structure declaration
> struct employee
> {
>    char fname[10];
>    char lname[10];
>    int emp_no;
>    char dept[15];
>    float hr_rate;
>    int wk_hrs;
> };

> //Prototypes
> void outputfunc();
> void inputdata();

Call these prototypes? What have you been smoking?

Quote:

> //Global variables
> struct employee emp[20]={0};
> struct employee *empp;

> //String tableture
> char *stbl[]=   // is it pointer or not?

No. It's an array of pointers to char.

And there I give up. The rest is just too dire to bear contemplating.

Look at each compiler message, be it error or warning, starting with the
first one.

When and only when you have solved the problem in your code highlighted by
the first error or warning, proceed to the second. Iterate until your code
compiles with no errors or warnings.

--
Richard Heathfield

"The bug stops here."



Wed, 05 Sep 2001 03:00:00 GMT  
 How can I fix these Error Messages (code below)

<Jack>

One of the things you are doing wrong is compiling C code as C++,
although to make it legal C you have to get rid of the "//" comments.

Quote:
> Error   : undefined identifier 'toupper'
> C_assign_4.c line 64   while(toupper(response) == 'Y')

Look up this function in your manual or online help.  Notice which
header contains its prototype.  Include that header.

Quote:
> Error   : ';' expected
> C_assign_4.c line 67   inputdata empp;

> Error   : undefined identifier 'outputdata'
> C_assign_4.c line 70   outputdata emp[i];
> Error   : ';' expected
> C_assign_4.c line 76   }

> Error   : expression syntax error
> C_assign_4.c line 78   }

> Error   : illegal function definition
> C_assign_4.c line 81   void inputdata(structure employee *empp)

> Warning : implicit 'int' is no longer supported in C++
> C_assign_4.c line 83   fflush(stdin);

> Error   : declaration syntax error
> C_assign_4.c line 83   (&__files[0])

> Warning : implicit 'int' is no longer supported in C++
> C_assign_4.c line 84   printf("%s", stbl[9]);

> Error   : declaration syntax error
> C_assign_4.c line 84   printf("%s", stbl[9]);

> Error   : declaration syntax error
> C_assign_4.c line 85   gets(emp.fname);

> Error   : ambiguous access to name found 'printf' and 'std::printf'
> C_assign_4.c line 87   printf("%s", stbl[10]);

> Error   : ambiguous access to name found 'gets' and 'std::gets'
> C_assign_4.c line 88   gets(emp.lname);

> //Include files
> //#include <conio.h>
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>

> //Macros
> #define sl printf("\n");
> #define dl printf("\n\n");

These are pretty silly macros, IMHO.  Why not just add the "\n" into
the string you are printing instead of creating more function calls
and more overhead?  What do you gain?

Quote:

> //Structure declaration
> struct employee
> {
>    char fname[10];
>    char lname[10];
>    int emp_no;
>    char dept[15];
>    float hr_rate;
>    int wk_hrs;
> };

> //Prototypes
> void outputfunc();
> void inputdata();

The two lines above are NOT prototypes in C, where a prototype shows
the return type AND the type of the arguments.  They ARE prototypes in
C++ but they specifically state that both functions take no arguments.
They are declarations in both C and C++, but only prototypes in C++.

Quote:
> //Global variables
> struct employee emp[20]={0};
> struct employee *empp;

> //String tableture
> char *stbl[]=   // is it pointer or not?

Actually it is an array of 16 pointers to char.

- Show quoted text -

Quote:
> {
>    "\n          IDNET EMPLOYEE DATABASE       ",//0
>    "          ***********************      ",//1
>    "          RECORD:                                         ",//2
>    "          FIRST NAME:                                     ",//3
>    "          LAST NAME:                                      ",//4
>    "          EMPLOYEE NUMBER:                                ",//5
>    "          DEPARTMENT:                                     ",//6
>    "          HOURLY RATE:                                    ",//7
>    "          WEEKLY HOURS:                           ",//8
>    "     Enter employees first name:          ",//9
>    "     Enter employees last name:           ",//10
>    "     Enter employee number:                       ",//11
>    "     Enter department:                                    ",//12
>    "     Enter hourly rate:                           ",//13
>    "     Enter weekly hours:                          ",//14
>    "     Do you want to enter a new record?" //15
> };

> int main(void)

> {  int i=0 , j;
>    float salary;
>    char response;

>    printf("%s", stbl[0]); sl;
>    printf("%s", stbl[1]); dl; dl;
>    printf("%s", stbl[15]); dl; dl;

>    response = getchar();

>    while(toupper(response) == 'Y')
>    {
>            empp = &emp[i];
>            inputdata empp;//Function call  

This is not a function call.  There are always parentheses () in a
function call.

Quote:
>            emp[i] = *empp;
>            outputdata emp[i];//Function call

Same thing here.

Quote:
>            printf("%s", stbl[15]);
>            response = getchar();

>            i++
>    }
>            for(j=0 ; j<i; j++)

This is a syntax error.  You don't have a statement after the
condition of the for statement.  So the ending brace of the function
might not be recognized.

Also if this is a C program you need to add:

   return 0;

here.

Quote:
> }

Because the compiler missed the closing brace of main(), it thinks you
are trying to define the function inputdata() inside of main(), which
is illegal.

Quote:
> //Header function for user input
> void inputdata(structure employee *empp)

If you are compiling as C++ you will get an error here even if you
clear up all of the errors before this, because in C++ your
declaration of this function above was also a prototype the same as:

void inputdata(void)

So now you have a mis-match.

The definition of a function requires an opening brace:
{

Quote:

>    fflush(stdin);

The function fflush() is not defined for input streams like stdin.

Quote:
>    printf("%s", stbl[9]);
>    gets(emp.fname);

Don't ever EVER use gets(), it is the most dangerous function in
either C or C++ because there is no way to use it safely.  What
happens if the user types 100 characters into your 10 character array
before pressing enter?  Crash!!!

- Show quoted text -

Quote:

>    printf("%s", stbl[10]);
>    gets(emp.lname);

>    printf("%s", stbl[11]);
>    gets(emp.emp_no);

>    printf("%s", stbl[12]);
>    gets(emp.dept);

>    printf("%s", stbl[13]);
>    gets(emp.hr_rate);

>    printf("%s", stbl[14]);
>    gets(emp.wk_hrs);
} Need a closing brace here.

If you are trying to learn C, do not compile the code as C++.  Also
your C++ compiler does not seem to be configured properly for
compiling C++.

And NEVER use gets.  See the comp.lang.c FAQ

http://www.eskimo.com/~scs/C-faq/versions.html

or the web page

http://home.att.net/~jackklein/ctips01.html#safe_gets

for alternatives to gets().

</Jack>
--
Do not email me with questions about programming.
Post them to the appropriate newsgroup.
Followups to my posts are welcome.



Wed, 05 Sep 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)

2. To get message that below to other process

3. help, the code below cannot work?

4. the code below can't run?

5. ADO error codes and messages

6. Determining what canned preprocessor symbols are available

7. Beginner [Q] Using Canned File Open/Save dialog

8. Help with compiling a "canned" program

9. Canned Dialogs

10. Fixed-size arrays as event args in managed code

11. Pls help me to fix the code!

12. pls help to fix the code!

 

 
Powered by phpBB® Forum Software