I get a warning saying: "Format specifies type 'char *' but the argument has type 'char'" for the student variable. I am copying/pasting the code out of a book into xcode and am not sure how to fix this. The only thing that prints in the console is "(lldb)". Any advice
#include <stdio.h>
void congratulateStudent(char student, char course, int numDays)
{
printf("%s has done as much %s Programming as I could fit into %d days.\n", student, course, numDays);
}
int main(int argc, const char * argv[])
{
// insert code here...
congratulateStudent("mark", "Cocoa", 5);
return 0;
}
void congratulateStudent(char *student, char *course, int numDays)
the %s
means that you are going to print a string ( array of chars)
and char student
this means that student is a char
type
so student here is not a pointer to a string
In order to change the student type from char to a string pointer you have to add asterisk to student char *student
In your code you are calling the congratulateStudent
with input parameter string "mark"
. So to support this string the input parameter student
should be defined as pointer of string
so you are missing the asterisk in the definition of student
The same thing for course
void congratulateStudent(char *student, char *course, int numDays)
Use Function signature like because you are passing string as argument to function in main
but function has character type argument..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With