[英]warning: implicit declaration
我有一項任務,我應該為我的計算機科學MOOC CS50。 在其中我必須通過哈佛網站上交作業,但它不接受我的代碼,而它說“警告:隱含聲明......”
有沒有辦法關閉它?
我有兩個函數,我正在使用islower()
和isupper()
,它們是導致掛斷的原因。
我的代碼似乎工作正常,它編譯和一切。 順便說一句,如果有人想告訴我我的代碼有多糟糕,那將是值得贊賞的。 我沒有得到很多(或任何)批評在網上上課。
#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
,那么你應該看到頂部的某個地方
#include <ctype.h>
要做到這一點。
看來您的頭文件沒有為這些函數聲明原型,因此函數本身被隱式地視為函數原型。 如上所述,添加所需的標頭。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.