0

My caesar program is not passing the cs50 check and the message I get is:
\ expected prompt for input, not output of "Please, enter your text:\n"

My code is as follows:

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

int main(int argc, string argv[])
{
string key = argv[1];

if (argc != 2)
{
    printf("Please, give me a valid key!\n");
    return 1;
}
else
{
 int k = atoi(key) % 26;

 printf("Please, enter your text:\n");

 string text = GetString();

 if (text != NULL)
 {
 for (int i = 0, n = strlen(text); i < n; i++)
   {
       int cipher = 0;

        if (isalpha(text[i]))
        {
            if (isupper(text[i]))
                {
                    cipher = ((text[i] - 'A' + k) % 26) + 'A';
                    printf("%c", cipher);
                }
            else
                {
                 cipher = ((text[i] - 'a'+ k) %26)+ 'a';
                printf("%c", cipher);
                }
        }    
            else
        {
            printf("%c", text[i]);
        }
   }
 }
printf("\n");
return 0;

} }

Any thoughts what is wrong?

Thank you,

Snezhina

1
printf("Please, enter your text:\n");

\ expected prompt for input, not output of "Please, enter your text:\n". Chekc50 is very strict about the expected output, simply remove printf

3
  • please if your questions are answered, mark the check box thus not appear as questions unanswered – MARS Aug 8 '16 at 21:08
  • Thank you - it worked! – SnezhinaT Aug 9 '16 at 7:18
  • I would be happy to marked it as answered - but not sure how.... – SnezhinaT Aug 9 '16 at 7:30

You must log in to answer this question.

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