7
votes
Accepted
pset6 - caesar - check50 error: "expected exit code 1, not 0"
main in Python no longer has a special meaning, but is a regular function, its name only chosen to conform to conventions based in C.
Try exit(1) instead of return 1.
Relevant python docs: https://...
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 ...
2
votes
Accepted
length of argv always change to 1?
Actually, it's not always changing to 1 on the last line. The result is always dependent on the input to argv[1]. Specifically, the last number printed depends on where the first 'a' appears in the ...
2
votes
Accepted
PSET2 Caesar - Stuck at 'isdigit' step: Do I need to learn about pointers, or is something else going on?
Its a simple and common issue with new programmers. ;-)
Yes, argv[] is an array of strings. So, argv[1] is a string. Now, say that argv[1] contains the string "cat". Then argv[1][0] ...
1
vote
Accepted
Strange CL output
I have no idea what this code is doing. But that doesn't really matter.
You said that the intent is to test the chars in argv[1] to see if they're digits. Well, there's absolutely no code here to do ...
1
vote
Accepted
Having problems with Pset2, argv[1]: program doesn't 'see' it
It's because you have return 1; after your if statement, that will just exit the program in that line and will not proceed to the next lines. That return should be inside your if statement therefore ...
1
vote
Accepted
CS50 Vigenere Segmentation Fault
It looks like it will fail here else if (isalpha(argv) == 0) (I did not read the code further).
argv is an array of strings. Review the man page for isalpha to be reminded that it takes a single ...
1
vote
Accepted
Resize infile won't read from argv
Let's look at some of the code:
char *tmp = argv[1];
tmp[strlen(argv[1]) + 1] = '\0';
...
for (int i = 0, n = strlen(tmp); i < n; i++) {
if (!isdigit(tmp[i])){
fprintf(stderr, "Usage:...
1
vote
error: unused parameter 'argv'
It's quite literally what it says. First, understand that all warnings are treated as errors because of one of the flags in the compile statement. This would otherwise just be a warning.
Now to the ...
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;
Only top scored, non community-wiki answers of a minimum length are eligible