警告:隐式声明 [英] warning: implicit declaration

查看:92
本文介绍了警告:隐式声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该为我的计算机科学MOOC CS50上交一份作业。在其中,我必须提交哈佛网站上的作业,但是当它显示警告:隐式声明...时,它将不接受我的代码。

I have an assignment I am supposed to turn in for my computer science MOOC CS50. In it I have to turn in the assignment over the Harvard website, but it won't accept my code while it says "Warning: implicit declaration..."

是有办法将其关闭吗?

Is there a way to shut that off?

我有两个正在使用的函数, islower() isupper( ),这就是导致挂断的原因。

I have two functions that I am using, islower(), and isupper(), and they are what is causing the hangup.

我的代码似乎可以正常工作,可以编译并执行所有操作。顺便说一句,如果有人想告诉我我的代码是多么糟糕,那将不胜感激。我在网上上课时没有太多(或任何)批评。

My code seems to work just fine, it compiles and everything. BTW if anyone wants to tell me how crappy my code is that would be appreciated. I don't get a lot (or any) criticism taking classes over the web.

#include <stdio.h>
#include "cs50.h"
#include <stdio.h>
#include <string.h>

int main(int argc, string argv[])
{
    int salt, cipherNum;
    char cipher[40];
    char letter;


    //// Greeting
    printf("Please enter the text to ceez...\n");
    //// grab text

    string txxt = GetString();


    if (argc == 2) // must have command line argument
    {

        salt = atoi(argv[1]) % 26;
        //printf("Salt: %d\n", salt);
    }

    else // yell at user if command line arg is not there
    {
        printf("Not cool! I need something to caesariphy...\n");
        return 1;
    }

    //~ 
    // This will iterate over each letter in the text
    for (int i = 0, n = strlen(txxt); i < n; i++)
    {
        // int letter = 'A'; i.e. 65 
        // Must Preserve Case

        //~ printf("%c---\n", txxt[i]);

        //if lower start from 'a'or 97
        if ( islower(txxt[i]) )
        {
            //~ printf("islower\n");
            letter = txxt[i];
            cipherNum = txxt[i];
            //~ printf("%c is the letter\n", letter + salt);
            //~ printf("%d is the cipherNumz\n", cipherNum);

            if ((letter + salt) > 122)
            { 
                //~ printf("letter + salt is > 90: %d \n", letter+salt);
                cipherNum = (96 + (cipherNum + salt) % 122);
                //~ printf("%c is the letters", cipherNum); 
            }
            else
            {
                cipherNum = letter + salt;
            }



            cipher[i] = cipherNum ;

        }
        else if ( isupper(txxt[i]))
        {

            letter = txxt[i];
            cipherNum = txxt[i];
            //printf("%c is the letter\n", letter + salt);
            //printf("%d is the cipherNumz\n", cipherNum);

            if ((letter + salt) > 90)
            { 
                //printf("letter + salt is > 90: %d \n", letter+salt);
                cipherNum = (64 + (cipherNum + salt) % 90);
                //printf("%c is the letters", cipherNum); 
            }
            else
            {
                cipherNum = letter + salt;
            }

            //printf("%c\n", cipherNum);
            cipher[i] = cipherNum ;
            //printf("testing12\n");    
        }
        else
        {
            cipher[i] = txxt[i];
        }
        //~ 

    }
    cipher[strlen(txxt) + 1] = '\0';
    printf("%s\n", cipher);


    return 0;
}


推荐答案

如果您使用的是标准 islower isalpha ,那么应该在顶部的某个位置看到

If you're using the standard islower and isalpha, then somewhere at the top you should see

#include <ctype.h>

要做到这一点。

这篇关于警告:隐式声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆