Problems with congratualateStudent


Very new to programming, and very new to C…
This is what i have so far :

#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[])
congratulatestudent(“Mark”, “Cocoa”, 5);
congratulatestudent(“Bo”, “objective-C” ,2);
congratulatestudent(“Ted”,“iOS”,5); return 0;

in congratulatestudent I keep getting a warning "format specifies type ‘char *’ but the argument has type 'char’
I get a breakpoint in the first line of the main, and all the rest " incompatible pointer to integer conversion passing ‘char [12]’ to parameter of type ‘char’"
well it has 12 for the first, then 7, then 4…
the only output I get is (lldb)

very confused because I can’t see where my code is different from the book’s!




For future reference, it looks better if you enclose any code samples inside the Code tags.


Thanks so much!
and I’ll keep that in mind for my future posts.

if you could, do you mind explaining why my original code didn’t work, even though it came straight from the book?



If you look closely at your function opening statement:

and compare it to mine:

which is how it is in the book, you will notice you missed off the *, which are pointers, and will learn more about them in Chapter 8.



Hm, interesting, my copy of the book doesn’t have the asterisks in there, oh well!