I'm pretty much brand new to C and am working my way through chapter 2 of "Teach Yourself C in 21 Days" at:
Teach Yourself C in 21 Days -- Table of Contents
I'm using Pelles C. I've typed the first program in and came up with the expected string of warnings and errors when I tried to compile it. The code and messages are below. The first error is "c(8): warning #2099: Missing type specifier; assuming 'int'." I can find nothing wrong with line or with any of the rest of the code. I even tried pasting in the code with the same results with the same list of warnings and errors.
Apparently there is something going on that I am not aware of. A shove in the right direction would be appreciated.
Thank you.
RVC
----------------------------------------------------------
Following is the code.
Code:
/* Program to calculate the product of two numbers */
#include <stdio.h>
int a, b, c;
int product (int x, int y);
main ()
{
/* input first number */
printf("Enter a number between 1 and 100:" );
scanf("%d", &a);
/* Input the second number */
printf("Enter another number between 1 and 100: ");
scanf("%d", %b);
/* Calculate and display the product */
c = product (a, b);
printf ("%d times %d = %d\n", a, b, c);
return 0;
}
/*Function returns the product of its two argguments */
int product (int x, int y)
{
return (x * y);
}
---------------------------------------------
Following are the warning and error messages
Building Multiply.obj.
C:\Documents and Settings\Rick Van Clief\My Documents\C programs\Multiply.c(8): warning #2099: Missing type specifier; assuming 'int'.
C:\Documents and Settings\Rick Van Clief\My Documents\C programs\Multiply.c(16): error #2039: Illegal expression.
C:\Documents and Settings\Rick Van Clief\My Documents\C programs\Multiply.c(16): error #2001: Syntax error: expected ')' but found 'b'.
C:\Documents and Settings\Rick Van Clief\My Documents\C programs\Multiply.c(16): warning #2234: Argument 2 to 'scanf' does not match the format string; expected 'int *' but found 'int'.
C:\Documents and Settings\Rick Van Clief\My Documents\C programs\Multiply.c(16): error #2001: Syntax error: expected ';' but found 'b'.
C:\Documents and Settings\Rick Van Clief\My Documents\C programs\Multiply.c(16): error #2001: Syntax error: expected ';' but found ')'.
C:\Documents and Settings\Rick Van Clief\My Documents\C programs\Multiply.c(16): error #2061: Illegal statement termination.
*** Error code: 1 ***
Done.