0

I dont know why this is wrong because it always says Caesar.c:17:13: error: use of undeclared identifier 'argv' even though it works for the ones before.

#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(int argc, string argv[])
 
{
    if(argc==2 && isdigit(argv[1]))
    return 0;
    else
 printf("Usage: ./caesar key\n");
 return 1;
}

int k= atoi( argv[1])

string plaintext=get_string("Plaintext:  ")



for (l=0;l < strlen(plaintext); l++)
{
    
    
    if(plaintext[l]=isupper)
    {
     int alphabetical_upper= ((atoi)plaintext[l])-65;
 int c_upper=(alphabetical_upper+k)%26;
 char ASCII_upper=(char(c_upper+65));
 printf("%c",ASCII_upper);
     //c=cipher text p=plaintext k=key
    }
    if(plaintext[l]=islower)
    {
        int alphabetical_lower= plaintext[l]-97;
     int c_lower=(alphabetical_lower+k)%26;
     char ASCII_lower=(char(c_lower+97));
     printf("%c",ASCII_lower);
    }
    }
    else
    
    {
        printf("%c",plaintext[l]);
    }
0
0

Be careful with your curly braces. Looks like you've closed off main after only a few lines. All the code after that } will not be part of the program.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .