0
我無法弄清楚我的代碼有什麼問題。我希望能夠在鍵入任何這些名稱作爲scanf函數,然後的話應該拿出的是我在printf的功能(當我嘗試鍵入一個名稱發生錯誤):我如何使用scanf來插入名稱並接收句子作爲輸出?
#include <stdio.h>
#include <math.h>
int main()
{
char *Name;
char *Carson;
char *Kam;
char *David;
char *Avery;
char *Taylor;
char *Brian;
printf("Enter a name:\n");
scanf("%s",Name);
printf("%s Hello Carson\n", Carson);
printf("%s Whats up?\n?", Kam);
printf("%s What are you looking at me for, I dont have any gum!!\n", David);
printf("%s Good luck with volleyball this weekend!!\n", Avery);
printf("%s Unauthorized user. Please back away!\n", Taylor);
printf("%s Hello user.\n", Brian);
return(0);
}
這樣做後,它會產生所有printf結果,不管我插入哪個名稱。對此有任何修復? –
@ user3247138查看更新後的答案。 – herohuyongtao