Hello friends,
I am learning C programming under linux recently, this is a example I tried, but got an error.
Code:
1 /* Insurance of driver - using logical operators */
2 #include <stdio.h>
3 main()
4 {
5 char sex, ms;
6 int age;
7 printf("Enter age, sex, marital status");
8 scanf("%d %c %c" &age, &sex, &ms);
9 if((ms == 'M') || (ms == 'U' && sex == 'M' && age > 30) || (ms == 'U' && sex == 'F' && age >25))
10 printf("Driver is insured");
11 else
12 printf("Driver is not insured");
13 }
~
root@gpl-vm:/lianxi/ch2# gcc -o insure insure.c
insure.c: In function ‘main’:
insure.c:8:19: error: invalid operands to binary & (have ‘char *’ and ‘int’)
root@gpl-vm:/lianxi/ch2# vim insure.c
root@gpl-vm:/lianxi/ch2#
the Linux distribution is
Code:
root@gpl-vm:/lianxi/ch2# cat /proc/version
Linux version 3.2.0-31-generic-pae (buildd@roseapple) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #50-Ubuntu SMP Fri Sep 7 16:39:45 UTC 2012
How to deal with this?