问题: 编译c程序时程序没问题运行时却报错
代码如下:
#include <stdio.h>
#include <string.h>
struct student{
char name[22];
int total;
};
int main()
{
int n;
struct student a[100];
struct student temp;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%s%d",a[i].name,&a[i].total);
}
for(int i=0;i<n;i++)
for(int j=0;j<=n-2;j++)
{
if(a[j].total<a[j+1].total)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
if(a[j].total==a[j+1].total&&strcmp(a[j].name,a[j+1].name)>0)//if后务必为==而非=;str(n)cmp为比较
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
for(int i=0;i<=n-1;i++)
{
printf("%s %d\n",a[i].name,a[i].total);
}
return 0;
}
运行结果(编译程序为VS-code):
gcc.exe: error: main: No such file or directory
gcc.exe: error: 3: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.
(使用Devc++运行不报错但不能运行)
尝试解决方法:
1.将编译程序VS-code卸载重新安装;
2.重新安装配置C编译器(MinGW-W64 GCC);
3.重装系统;
求各位大家指点指点,帮忙解决一下程序不能运行的问题