0

When I checked my program, everything worked except Hax0r2. It says

expected output, not a prompt for input 

Last time I came across this problem, it had to do with not including printf.

But this time I wrote:

int main(int argc, string argv[ ])
{
    if (argc != 2)
    {
        printf("Enter a key too!\n");
        return 1;
    }

    string key = argv[1];

    for (int j = 0; j < strlen(argv[1]); j++)
    {
        char m = argv[1][j];

        string l = GetString();

        for (int i = 0; i < strlen(l); i++)
        {

            if (!isalpha(m))
            { 
                 printf ("Make sure there are only letters in the key.\n");
                 return 1;
            }
        }
    }

// Other Code
// Other Code

}//main        

What am I doing wrong here?

Thank you :)

(I excluded the parts that aren't relevant to my question so this wouldn't be unnecessarily long)

1
  • for any answer you must show the complete code where the bug could possibly be present, not just "..."
    – abhishek
    Jun 12 '16 at 18:33
0

Put

string l = GetString();

before the first for Loop. You can put after

string key = argv[1];

GetString() function is being called again and again as per the length of key string.

0

Is the issue that you are incorrectly referencing the function GetString(); and the actual function name is get_string()?

1
  • The function used to be 'GetString()` in 2016 when this question was asked; The current function in the cs50 library is get_string().
    – robert_x44
    Sep 18 '17 at 17:09

You must log in to answer this question.

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