mercredi 19 juillet 2017

How to use an isalpha result to initiate an if statement?

Okay, so I have a for loop that checks through every letter of a string to make sure that the string is made entirely of alphabetical characters before moving on to the next stage of the program.

However, I am having trouble with my if statement that is supposed to run if the "isalpha" function comes back false.

string keyword = argv[1];
for (int i = 0; i < strlen(keyword); i++)
{
    char letter = keyword[i];
    if (isalpha(letter) = false)
    {
        printf("Only use alphabetical characters in your key\n");
        return 1;
    }

I am getting the error:

error: expression is not assignable if (isalpha(letter) = false)

How can I get an if statement that initiates due to a isalpha being false?

How is the following wrong?

if (isalpha(letter) = false)

Aucun commentaire:

Enregistrer un commentaire