简体   繁体   中英

Implicit declaration of functions

I am getting this error from the isdigit and isalpha functions

 warning: implicit declaration of function ‘isdigit’ [-Wimplicit-function-declaration]
   numberCheck = isdigit(englishWords[i]);
  warning: implicit declaration of function ‘isalpha’ [-Wimplicit-function-declaration]
   letterCheck = isalpha(englishWords[i]);

my code is:

char * inputEnglish()
{
    char englishWords[MAX_LENGTH];
    char required[MAX_LENGTH] = {"message="};
    char * messageToBeSent;
    int i;
    int numberCheck;
    int letterCheck;
    i = 0;

    printf("Please enter the word you'd like to translate\n");
    fgets(englishWords, MAX_LENGTH, stdin);
    for(i = 0; i < (strlen(englishWords) + 1); i++)
    {
            numberCheck = isdigit(englishWords[i]);
            letterCheck = isalpha(englishWords[i]);
            if((numberCheck != 0)  || (letterCheck != 0))
            {
                    printf("Please enter valid Input");
            }
    } 
    strcat(required, englishWords);
    messageToBeSent = malloc(sizeof(char)*(strlen(required)+1));
    strcpy(messageToBeSent, required);

    return (messageToBeSent);
}

How do i get rid of these warnings?

You're using functions that the compiler has not been informed about, so it makes assumptions, in particular about the return type. As @ShafikYaghmour says in the comments, the proper include file will provide the compiler with the necessary information, even though (in this case) your code will probably work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM