Hot answers tagged

3 votes
Accepted

What does argc and argv have to do with cryptography? Why are we learning about these arguments?

What do argc and argv have to do with the subject of cryptography? Nothing. But they DO have a lot to do with how you get data into a program when it is started. Just in case you didn't ...
Cliff B's user avatar
  • 68.4k
1 vote
Accepted

PSet 2 - Why will it still pass negative numbers?

There are a few problems here. First, it's checking whether a string, argv[1], is greater than 0, which will always be true, no matter what the number that results after the atoi() call may be. All ...
Cliff B's user avatar
  • 68.4k
1 vote

why argc is not counting all commands?

Because the arguments passed to your program are only 2: the name of your program (./arg-0) the argument you pass to it (pri). The > file.txt part of the command is used by the command line to ...
ChrisG's user avatar
  • 7,376
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;
iMarketingGuy's user avatar

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