关于编译错误(本地正常运行)
  • 板块灌水区
  • 楼主ISTP
  • 当前回复9
  • 已保存回复9
  • 发布时间2022/11/30 11:48
  • 上次更新2023/10/27 00:56:53
查看原帖
关于编译错误(本地正常运行)
528540
ISTP楼主2022/11/30 11:48

rt.帮别人调代码,给我自己整不会了,可能跟不是自己写的有一定关系

用的万能头 用的 using namespace std; 为蛤会说 gets 没定义呢

题目:

代码:

#include<bits/stdc++.h>

#define max 1000002
using namespace std;
char s[max];
int main()
{
    int f = 0;
    gets(s);
    int lens = strlen(s);
    for (int i = 0; i < lens; ++i)
    {
        if (s[i] == ' ') {
            f = 0;
        }
        else {
            f++;
        }
        if (f % 2 != 0 && s[i] > 'Z') {
            s[i] -= 32;
        }
    }
    for (int i =0; i < lens; ++i) 
    {
        printf("%c", s[i]);
    }
    return 0;
}

错误信息:

/tmp/compiler_8nmzo0_5/src: 在函数‘int main()’中: /tmp/compiler_8nmzo0_5/src:9:5: 错误:‘gets’ was not declared in this scope; did you mean ‘fgets’? 9 | gets(s); | ^~~~ | fgets

2022/11/30 11:48
加载中...