C31059 2022-08-12 15:03
浏览 15
已结题

编译c程序时程序没问题运行时却报错

问题: 编译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.重装系统;
求各位大家指点指点,帮忙解决一下程序不能运行的问题

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 已结题 (查看结题原因) 8月12日
    • 创建了问题 8月12日

    悬赏问题

    • ¥15 系统 24h2 专业工作站版,浏览文件夹的图库,视频,图片之类的怎样删除?
    • ¥15 怎么把512还原为520格式
    • ¥15 MATLAB的动态模态分解出现错误,以CFX非定常模拟结果为快照
    • ¥15 求高通平台Softsim调试经验
    • ¥15 canal如何实现将mysql多张表(月表)采集入库到目标表中(一张表)?
    • ¥15 wpf ScrollViewer实现冻结左侧宽度w范围内的视图
    • ¥15 栅极驱动低侧烧毁MOSFET
    • ¥30 写segy数据时出错3
    • ¥100 linux下qt运行QCefView demo报错
    • ¥50 F1C100S下的红外解码IR_RX驱动问题