當運行使用Xcode的這個小C
腳本,我得到這個消息:浮動看作是一個雙
Format specifies type 'float *' but the argument has type 'double" at scanf("%f", v) and scanf("%f", i).
我不明白這一點,因爲我還沒有宣佈任何double
類型變量。
int main(int argc, const char * argv[]) {
char choice[10];
float v;
float i;
float r;
printf("What would you like to calculate?: ");
scanf("%s", choice);
printf("\nYou chose: \n""%s", choice);
if (strcmp(choice, "r") == 0)
{
printf("\nPlease enter voltage (V): \n");
scanf("%f", v);
printf("\nPlease enter current (I): \n");
scanf("%f", i);
r = v/i;
printf("%f", r);
}
}
任何想法?