Please Help With C Program 
Author Message
 Please Help With C Program

Quote:
> void avgFun(int grd1, int grd2, int grd3, float avg);

proto is not the same as the function
Quote:
>         avgFun(int *grd1, int *grd2, int *grd3, float *avg)
>         {
>                 *avg = (*grd1+*grd2+*grd3) / 3;
>                 return(0);
>         }



Sat, 08 Sep 2001 03:00:00 GMT  
 Please Help With C Program

Quote:

> I'm trying to write a program and I keep getting an error saying:
> error C2664: 'avgFun' : cannot convert parameter 1 from 'int *' to 'int'
>         This conversion requires a reinterpret_cast, a C-style cast or
> function-style cast

> Here's the code:

> #include <stdio.h>

Check these out, see if they all "agree" or match:
1. The prototype or declaration:
Quote:
> void avgFun(int grd1, int grd2, int grd3, float avg);

[snip]

2. The call or execution of the function:

Quote:
>     avgFun(&grd1, &grd2, &grd3, &avg);  // call function

[snip]

3. The definition of the function

Quote:
>     avgFun(int *grd1, int *grd2, int *grd3, float *avg)
>         {
>                 *avg = (*grd1+*grd2+*grd3) / 3;
>                 return(0);
>         }

If you haven't seen it already, the prototype is different than the call and
definition of the function.  The prototype declares the arguments as integers;
the others use pointers to integers.

That wasn't difficult.

--
Thomas Matthews



Sat, 08 Sep 2001 03:00:00 GMT  
 Please Help With C Program
The first, why don't read and try to understand each compiler error. The purpose
of error and warning message is to tell to programmer that something wrong.

Quote:
> void avgFun(int grd1, int grd2, int grd3, float avg);

> main()
> {
>         int grd1, grd2, grd3;  // declare variables
>         float avg;

<snip>

Quote:
>         avgFun(&grd1, &grd2, &grd3, &avg);  // call function

<snip>

The avgFun() function prototype declared above was different.
"error C2664: 'avgFun' : cannot convert parameter 1 from 'int *' to 'int'"
says that the first parameter you are passing in the function call is of type
"int*" and in the prototype declared "int".



Sun, 09 Sep 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!

2. Please help!!!!Please help!!!!Please help!!!!

3. Newbie: separate big .cs file into small .cs files

4. Someone Please Help Me - I Help You in Any Software Queries/Programming/Coding

5. Need help on this programming problem ( PLEASE HELP!!!)

6. Problem #30 on http://cs.nmu.edu/programming/c/problems.htm

7. SoftEng or CS Graduate Program Search

8. FS: Programming and CS Books --- CHEAP

9. 1995 UT IEEE CS National Programming Contest

10. Good CS Programs

11. IEEE CS National Programming Contest [Addendum3]

12. 1993 IEEE CS National Programming Contest Notice

 

 
Powered by phpBB® Forum Software