Hot answers tagged

1

Interesting interaction between different parts of the code. When there is an 'a' or an 'A' in the key it will fail because of a unique interaction in your code. The code first converts all of the key chars to numbers between 0 and 25 inclusive. The problem lies in the conversion of the a's to 0. Later in the code, the following code appears in the for ...


1

int x = (argv[1][j])-'0'; looks like your problem. You are subtracting the ascii value of the 0 symbol from the character in argv[1][j]. In effect, you have done int x = (argv[1][j])-48; I don't understand why you are subtracting either 0 or the ascii value of 0 here. Instead of those 3 lines of code, you could consolidate them into one line and eliminate ...


1

if (argc!=2 || isalpha(argv[1])==0) isalpha() takes a single character as input. You're trying to stuff it with an entire string. Instant seg fault. Note that when argc!=2 is true, then the isalpha isn't evaluated or executed because as soon as any part of an or statement is found to be true (they're generally evaluated left to right), the remaining ...


1

it means that when you start your app without a command line parameter that you should display an error message.


Only top voted, non community-wiki answers of a minimum length are eligible