Argument type choice in congratulateStudents


I was wondering if anyone could explain why congratulateStudent used char pointer instead of char type for the arguments. I was also wondering how the compiler handles the given arguments when the function is called. Once the function is called, does the compiler allocate memory to the arguments then chooses the value in the address the complier made for the arguments?

Thanks for the help!

A function with the signature void congratulateStudent (char name) accepts only a single character as argument,
whereas a function with the signature void congratulateStudent (const char * name) accepts a sequence of characters as argument.

void congratulateStudent ('A')
void congratulateStudent ("Foo Bar")

Thanks for the response! I read more and C does not have a string type so it uses char arrays for strings. Does this mean that char *name is a pointer to a char array? Or is just a char array?

A variable of type char * can be used to hold a pointer to (or address of) a character. Thus, if you have the address of the first character in a sequence of characters, and if you also have the means of detecting the end of the sequence then you can use that sequence as an array of characters. However, unlike languages such as Swift, C does not provide a type for array objects that keep track of their lengths. The programmer has to do the hard work.