0

I can't understand this error.

caesar.c:22:20: error: expected expression string p = get_string(); ^ /usr/include/cs50.h:109:53: note: expanded from macro 'get_string'

define get_string(...) get_string(NULL, VA_ARGS)


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

int main(int argc,string argv[])
{
    //validition of the key

    if(argc != 2 || atoi(argv[1]) < 0)
    {
        printf("Something went wrong!!\n ");
        return 1;
    }
    else
    {
        //conver the key into int
        int k = atoi(argv[1]);
        //prompt user for plaintext
        printf("plaintext: ");
        string p = get_string();

        //ciphering
        printf("ciphertext: ");
        for(int i = 0, n = strlen(p); i < n; i++)
        {
            if (isalpha(p[i]))
            {
                if (isupper(p[i]))
                {
                    printf("%c", ((((int) p[i] - 65) + k) % 26) + 65);
                }
                else
                {
                    printf("%c", ((((int) p[i] - 97) + k) % 26) + 97);
                }
            }
            else
            {
                printf("%c", p[i]);
            }
        }
        printf("\n");
    }


}
2

You must log in to answer this question.

Browse other questions tagged .