I am trying to print the out put of name and phone. Keeps showing this two errors in terminal
format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’
and
format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’
my code:
int main(void)
{
char name,phone;
int age;
printf("Kindly input your name, age and phone number");
scanf("%s %s %d", &name, &phone, &age);
printf("%s %s %d\n", name, phone, age);
return 0;
}
The error message means that in this call of
printfargument expressions
nameandphonehaving the typecharare promoted to the typeintand there is used the conversion specification%sdesigned to output strings instead of integers.Instead of declaring these variables as having the scalar type
charyou need to declare them as having a character array type to be able to store strings.And you should change the prompt
like
For example