【发布时间】:2015-08-15 17:40:49
【问题描述】:
#include "stdafx.h"
int main() {
char name;
printf("What is your name:"); // I enter my name..
scanf_s("%c", &name); // Should grab my name in this case (Brian)
printf("Hello, %c\n", name); //Should print "Hello, Brian."
return 0;
}
怎么了?为什么它不存储全名而只存储第一个字母?
【问题讨论】:
-
我相信你想要 %s。 %c 是单个字符
-
在使用单个字符输出格式时,您实际上还期望什么,例如
printf("Hello, %c\n", name);??
标签: c visual-studio