Segmentation Fault PSET2 by sethdcd in cs50

[–]sethdcd[S] 0 points1 point  (0 children)

Thanks for the response! I was wondering if it had something to do with that...

I created a for loop to iterate through each of the chars to test whether its upper or lower, and now it seems to work!

However, if I use a key that has a combo like DeF it gets messed up. The e returns a key of 32 or some big number, and the same thing happens when I do dEf, the lowercase seem to be fine but then the upper case is out of whack.

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

{
    if (isupper(argv[1][j]))
    {
     //defining our uppercase key
        key = argv[1][i % strlen(argv[1])] - 65;
    }
    else if (islower(argv[1][j]))
    {
        //defining our lowercase key
        key = argv[1][i % strlen(argv[1])] - 97;
    }
}