可能重复:
Why doesn't scanf need an ampersand for strings and also works fine in printf (in C)?C:为什么不能在scanf()函数中使用字符串?
在C当我们使用scanf()
函数来获取用户的输入,我们总是变量之前使用&
迹象。 例如:
scanf("%d", &number);
scanf("%c", &letter);
这保证我们的输入被存储在适当的地址。但是在字符串的情况下,我们不使用&
。
这是为什么?