Why does while compiling it this error appear?

#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int main(int argc , string argv[])
    string s ;
    int i = atoi (argv[1]);
    if (argc==2)
        s = get_string ("Enter plaintext ");

    for (int z=0;z<strlen(s);z++)
        if (isalpha(s[z]))
            printf("%c", (((s[z] + i) - 65) % 26) + 65);    


caesar.c:13:19: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/stdlib.h:148:33: note: nonnull attribute specified here
Segmentation fault

That's not a compiler error, it's a runtime error. If you ran the program without a parameter (the key number), it will error out because the code isn't checking to make sure there's 1 parameter, i.e., argc == 2, as stated in the problem spec.

Also, please spend some quality time with style50 and learn how to format the code.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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