【发布时间】:2014-04-30 18:00:33
【问题描述】:
我从 main() 中的用户那里得到了一些字符串,我想将这些字符串作为参数传递给另一个函数。当我运行调试时,我可以看到只有最后一个参数保存输入的字符串,而前两个参数为空。当我将字符串定义为全局时,一切正常,怎么会?
我还尝试在从用户那里获取字符串后立即打印它们并且它们存储正常。
下面是部分代码:
char temp_destination[20];
char temp_old_date[6];
char temp_new_date[6];
printf("Please enter destination, flight date and new date to update\n");
printf("Destenation: ");
scanf("%s",temp_destination);
printf("Current date: ");
scanf("%s",temp_old_date);
printf("New Date: ");
scanf("%s",temp_new_date);
update_flight_date(database,temp_destination,temp_old_date,temp_new_date);
【问题讨论】:
标签: c string function arguments