Code:
kermit@minty ~/cprogs/board $ gcc -Wall -o caser caser.c
caser.c:3: warning: return type defaults to `int'
caser.c: In function `maian':
caser.c:13: warning: too few arguments for format
caser.c:14: warning: too few arguments for format
caser.c:19: warning: format argument is not a pointer (arg 2)
caser.c:22: error: `Default' undeclared (first use in this function)
caser.c:22: error: (Each undeclared identifier is reported only once
caser.c:22: error: for each function it appears in.)
caser.c:22: error: parse error before numeric constant
caser.c:24: error: `Break' undeclared (first use in this function)
caser.c:37: warning: format argument is not a pointer (arg 2)
caser.c:39: error: parse error before '=' token
caser.c:7: warning: unused variable `hlhrs'
caser.c:8: warning: unused variable `ot'
caser.c:9: warning: unused variable `othol'
caser.c:10: warning: unused variable `check'
caser.c: At top level:
caser.c:47: error: parse error before string constant
caser.c:47: warning: type defaults to `int' in declaration of `scanf'
caser.c:47: error: conflicting types for 'scanf'
caser.c:47: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
caser.c:47: error: conflicting types for 'scanf'
caser.c:47: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
caser.c:47: warning: data definition has no type or storage class
caser.c:49: error: parse error before string constant
caser.c:49: warning: type defaults to `int' in declaration of `Printf'
caser.c:49: warning: data definition has no type or storage class
caser.c:50: error: parse error before string constant
caser.c:50: warning: type defaults to `int' in declaration of `scanf'
caser.c:50: warning: data definition has no type or storage class
caser.c:51: error: parse error before '*' token
caser.c:55: error: parse error before string constant
caser.c:55: warning: type defaults to `int' in declaration of `printf'
caser.c:55: error: conflicting types for 'printf'
caser.c:55: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
caser.c:55: error: conflicting types for 'printf'
caser.c:55: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
caser.c:55: warning: data definition has no type or storage class
caser.c:57: error: parse error before string constant
caser.c:57: warning: type defaults to `int' in declaration of `printf'
caser.c:57: warning: data definition has no type or storage class
wow man - you have got yourself some problems there. First of all, you need to learn to type better.
Now the one function necessary in every C program (except maybe some embedded programs??) is the main function - not 'maian ', and it returns an int - you can declare it like this:
Code:
int main(void)
{
/* other code */
return 0;
}
Also, you should #include <stdio.h> when you are using functions from that library, such as printf and scanf.
This:
is as bad as using the gets function, in that you can overrun a buffer, as there is no way to control user input. Have a look at the FAQ on how to Get a line of text from the user/keyboard.
Code:
printf("Your pay this week will be $,%check");
You really ought to read some documentation on the proper usage of printf. Generally speaking, when you want to display an int (as in the variable check) you would do something like this:
Code:
printf("Your pay this week will be $%d\n", check);
When you are grabbing a scalar value with scanf, you need to use the 'address of' operator like so:
And what did you mean by this?
Code:
(hlhrs * 2) + (ot * 1.5) + hours - (hlhrs + ot) = check}
Had you wanted to assign the result of that computation to some variable? Maybe you meant to do this?
Code:
check = (hlhrs * 2) + (ot * 1.5) + hours - (hlhrs + ot)}
Nope - that won't work either. 'set' is not a valid C keyword, and you cannot use spaces in variable names, so what you get is this:
Code:
caser.c:26: error: `set' undeclared (first use in this function)
caser.c:26: error: (Each undeclared identifier is reported only once
caser.c:26: error: for each function it appears in.)
caser.c:26: error: parse error before "pay"
Get rid of 'set'
Code:
Break;
linker output:
caser.c:27: error: `Break' undeclared (first use in this function)
caser.c:27: error: (Each undeclared identifier is reported only once
caser.c:27: error: for each function it appears in.)
Careful with your typing - 'Break' is not a C keyword, but 'break' is.
Next....
Code:
printf("Good Day to you %s.");
You never passed 'name' to printf as an argument to correspond with %s. Try:
Code:
printf("Good Day to you %s.\n", name);
also for,
Code:
printf("%s"
"please chose one of the following choses so we know your hourly pay.");
..you may as well do:
Code:
printf("Please chose one of the following choses so we know your hourly pay.\n");
Well, you missed a semi-colon here, but that is the least of your problems. You cannot do things like what you have - did you mean
Code:
check = pay * hours;
??
Again, watch those capitals! its printf, not Printf
Code:
Default 1:
set pay = 10;
Break;
You can have a default case, but it looks like this:
Code:
switch (pay) {
case 1:
pay = 10;
break;
case 2:
pay = 20;
break;
case 3:
pay = 30;
break;
case 4:
pay = 50;
break;
default:
/* some stuff to catch the case that 'can't happen */
break;
}