Hot answers tagged

6 votes

How to handle "lack of argv[1]"

GAR, figured it out. I didn't take the details of "your program should yell at you" literally. This works now. if (argc != 2) { printf("YOU SCREWED UP!"); return 1; }
user avatar
1 vote

CERT_NOT_YET_VALID

Figured it out. update50 and restart.
user avatar
1 vote
Accepted

PS2 Vigenere not shifting upper and lowercase correctly

Your issue is that you are only using the first letter of the key. int k = shift (key[0]); You need to use each subsequent letter as you move along ciphering the plaintext. That is the challenge ...
user avatar
  • 18.4k
1 vote
Accepted

Vigenere error compiling: type int vs unsigned long

I assume the % strlen(key) is causing some type conversion. Your logic is wrong. First iterate the key to ensure all characters are alphabetic, and maybe also uppercase the key there if you want. ...
user avatar
  • 20.7k
1 vote
Accepted

Misprinting the vignere cipher

Instead of printing non-alphas without encoding them, this code is printing the next encoded letter for each preceeding non-alpha. In other words, if the key was a (meaning don't encode, just echo ...
user avatar
  • 63.5k
1 vote
Accepted

Pset2 caesar unused variable

Your instincts are more or less correct. You have actually declared key twice, once as a global and a second time as a local var inside main(). Specifically, the line int key = atoi(argv[1]); is the ...
user avatar
  • 63.5k
1 vote

Assing argv[1] to a string variable (vigenere)

The best and most efficient way is to out grow CS50.h use char* newString = argv[1]; argv will always be there so you might as well point to it or use it.
user avatar
  • 186
1 vote

Assing argv[1] to a string variable (vigenere)

string keyword = argv[1]; will work because you are assigning the address of string argv[1] to keyword. You can now treat keyword as a char array and access the individual characters as keyword[i]. ...
user avatar
  • 63.5k
1 vote

How to handle "lack of argv[1]"

I had the same error until I moved my declared variables AFTER the if... if (argc !=2) { printf("Oops! Only 2 arguments allowed"); return 1; } int k = atoi(argv[1]); string p;
user avatar

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