我正在阅读“Objective-C Programming The Big Nerd Ranch Guide”这本书
。
他们给出了这个代码:
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);
}
并用这个调用它:
congratulateStudent("Mark", "Cocoa", 5);
这给了我这个警告:
Format specifies type 'char *' but the argument has type 'char'
这本书有错吗?
最佳答案
可能有错别字。
Char
表示单引号中只有一个字符,如'a'
。
常量字符串在双引号中并衰减为 char*
或字符指针,如下所示。
"Hello World"
关于objective-c - 将 char 传递给 c 中的函数(这本书错了吗?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12828054/