jeudi 2 février 2017

Faulty if statement (beginner)

I'm on week 2 of cs50 edx, and keep getting the following error when trying to compile: caesar.c:23:7: error: expected expression if (isalpha(encryptme[p]) = true){ ^

Here's my code:

#include <stdio.h>
#include <cs50.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main(int argc, string argv[])
{
    if (argc !=2) { 
    printf("ERROR: Must pass exactly two command line arguments!\n");
    return 1;}  

   string num = argv[1];
   int i = atoi(num);

   printf("plaintext: ");

   string encryptme = get_string();

   printf("cyptertext: ");

   for (int p = 0; p <= strlen(encryptme); p++)(
      if ( isalpha(encryptme[p]) = true){
      printf("%c",encryptme[p]+i%26);
      }
   )
}

Stared at this for over an hour, have searched for over an hour, please find my undoubtedly idiotic error!

Aucun commentaire:

Enregistrer un commentaire