【发布时间】:2015-11-29 14:34:47
【问题描述】:
这是我的主要功能的一部分,我将 char 数组传递给 get file_file(file) 函数。
int main(int argc, char** argv) {
char file[60];
get_file(file);
return (EXIT_SUCCESS);
}
这是我做的获取文件的方法。我只是希望它将“文件”返回给主要方法以传递给多个其他方法,但是根据调试,我在 scanf 语句之后直接得到分段错误。
void get_file(char file) {
printf("What file do you want?");
scanf(" %s",file);
//do other stuff
return file;
}
【问题讨论】: