嗨匹配輸出下面我有一個C函數:輸入不使用C
int method2(){
int userInput;
printf("Please enter your age: ");
scanf("%d", &userInput);
fpurge(stdin);
printf("You are %d years old. \n", &userInput);
int retval = 0;
return retval;
}
該函數將年齡,並返回一個強大的句子相同的值。
所以,當我運行它作爲類型12年齡。我得到
You are 1606416204 years old.
'printf'中的'&userInput' - >'userInput'閱讀一本書以理解爲什麼'printf'和'scanf'在這裏有所不同。 –
'userInput'的計算結果是userInput的地址,而userInput的計算結果是它的值。 – Rohan