【问题标题】:Can anyone tell me in details, why i am watching warning for this program? [duplicate]谁能详细告诉我,为什么我正在观看该程序的警告? [复制]
【发布时间】:2018-12-05 22:20:11
【问题描述】:
#include<stdio.h>
#include<string.h>
int main()
{
    char input[102], output[210];
    int i=0;

    scanf("%s",input);

    for(i=0;i<strlen(input);i++)
    {
        if(tolower(input[i])=='o'|| tolower(input[i])=='i' || tolower(input[i])=='a' || tolower(input[i])== 'e'
           || tolower(input[i])=='u')
            continue;
        else
            printf(".%c",tolower(input[i]));

    }
}

当我运行这段代码时,它会显示以下警告,

函数‘tolower’的隐式声明[-Wimplicit-function-declaration]

    if(tolower(input[i])=='o'|| tolower(input[i])=='i' || tolower(input[i])=='a' || tolower(input[i])== 'e'

有时输出是意外的,比如我输入输入:

输入::xnhcigytnqcmy

输出::.x.n.h.c.g.y.t.n.q.c.​​m.y

预期输出:

.x.n.h.c.g.t.n.q.c.​​m

那么谁能告诉我我在哪里犯了错误?

【问题讨论】:

    标签: c tolower implicit-declaration


    【解决方案1】:

    tolower() 的原型是 &lt;ctype.h&gt;。你必须包含这个头文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-25
      • 2010-10-06
      • 1970-01-01
      • 2015-03-22
      • 2020-04-22
      • 2021-09-07
      相关资源
      最近更新 更多