2
votes
My output for greedy.c is correct when I check it manually but not when I check it using check50
An unintended benefit of CS50 is learning how to read and adhere to specifications, an invaluable skill if one intends to code for pay :)
From the spec:
Incidentally, so that we can automate some ...
- 27.5k
2
votes
Accepted
c prog - Generate ''ALPHABET'' and ''alphabet'' in arrays, wrong output
The problem is simple. You have created two string arrays. Each holds the 26 letter alphabet, one lower case, the other upper case. They are created in sequential memory. In this case, the UC array ...
- 66.7k
2
votes
Accepted
Question about Pset2 Caesar Code issue
It's not enough to apply the %26 to the cipher. You need to shift your character into range 0-25
plain[i] - 'A'
then add cipher
plain[i] - 'A' + cipher
then apply %26 to wrap numbers back to 0-25
...
- 20.8k
1
vote
Pset2 - Substitution - "Output not valid ASCII text" error despite correct cipher output
Your code reads from the outside of cipher which contains unknown values because your cipher is not terminated by \0.
Here is the link that you can debug memory errors or unexpected behavior in the ...
- 450
1
vote
Accepted
pset2 Vigenere - output overwriting "ciphertext"
You've got a few issues, but the one most affecting you is that you are printing values in your shift function that aren't printable. You shouldn't be printing anything in your shift function. What ...
- 18.5k
1
vote
Accepted
Error: greedy cash input of 0.41 yields output of 4
check50 does an automated test.
This means that some program will look at your output, and tries to see whether it is the same as expected.
Actually, the specifications say:
we ask that your ...
- 999
1
vote
Accepted
pset4 resize less output issues
The problem is in vertical scaling - the code isn't complete.
The code is scaling horizontally just fine. It also looks like it's set up to repeat processing each line for vertical replication, but ...
- 66.7k
1
vote
PSet2 Caesar Program: Single Unexpected Output (Otherwise working)
The double characters come from two printfs being executed for one character (you have an if and an if-else, the first might print sometimes, the other would always print).
The way you're dealing ...
- 20.8k
1
vote
Accepted
Greedy not printing
It does print it, but as you haven't included any '\n' after it, it's printing at the beginning of your command line.
printf("%d\n", coins); //Output
That ought to fix it.
HTH
If this answers your ...
- 834
1
vote
Accepted
greedy failing input of 4.2 even though it's outputing the correctly formatted answer!
It's not the \n line feed. (I wish they'd fix that slightly misleading message.)
It's giving you an error because 22 is the wrong answer! 22 coins means 16 quarters, 1 dime, 1 nickel and 4 pennies. ...
- 66.7k
1
vote
Accepted
Encrypted text doesn't appear on screen
Actually, it is processing your encoded letters. Your formula for encoding the letters is wrong. It produces ASCII values that correspond to unprintable control characters.
You should review the ...
- 66.7k
1
vote
Help with fseek and fgets
Fseek works by moving the file pointer, indicated by the FILE pointer in our case, forward or backward. So whenever you use functions that work with file streams, you should keep in mind where the ...
Only top scored, non community-wiki answers of a minimum length are eligible