c语言程序错误问题

来源:百度知道 编辑:UC知道 时间:2024/05/26 10:55:39
#include<stdio.h>
char main(void)
{
char file[20];
printf("Enter the file name:\n");
scanf("%s",file);
return(file);
}
错误是
Illegal return type: found 'char *', expected 'char'.
怎么改
如何改为所声明的char类型?

#include<stdio.h>
char main(void)
{
char file[20];
printf("Enter the file name:\n");
scanf("%s",file);
return(file);//返回的是指针file,在C/C++中数组名既可以表示其指针~表明 他的存贮位置
}
所以改成char* main(void) //应该就没问题了吧~

char main(void) 有这么写的吗,main返回是char?????

而且,return语句的file是char*,不是所声明的char类型。

你既然主函数是char类型的,那怎么能写void呢