Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
The problem set for Week 2 continues with the C programming language used in problem set 1.
5
votes
Accepted
What does " 'GetString' is deprecated" mean? How do I fix it?
From the What's new? in CS50 2017 document:
CS50 Library
To be more consistent with stylistic conventions in C, we’ve renamed the functions in the CS50 Library as follows:
GetChar is now get_char
Get …
4
votes
extra characters in Vigenere pset2 2016
First, notice that the check50 result and your result have different nonsense characters at the end.
Recall from the Week 2 Lecture "More on Strings" (starting around 1:18) the discussion about stri …
4
votes
Accepted
vigenere sometimes prints extra characters at the end of ciphertext in an unpredictable pattern
The problem comes because cipher is declared a char array here char cipher[strlen(plain)];, but printed out using a string (aka char*) format here printf("ciphertext: %s\n", cipher);.
Remember, the t …
4
votes
Accepted
This should be right (Caesar)
The output does not match the spec. This plaintext : should be this plaintext:. The same with ciphertext:. There is no space between the word and the :. While this may seem "overly strict", it is good …
4
votes
Accepted
Caesar code only works correctly when I add a random printf statement
It's a memory thing, as in you will get different results based on what is in memory.ctxt is declared as an array of chars. Here printf("ciphertext: %s\n", ctxt); is treating it like a string (viz th …
4
votes
Accepted
Pset 2 - Substitution - Error - handles multiple duplicate characters in key
The problem is this cipher key BBCCEFGHIJKLMNOPQRSTUVWXYZ should not perform the encoding, it should give an error. From the spec [emphasis added]:
If the key is invalid (as by not containing 26 …
3
votes
Accepted
Pset 2 Caesar doesnt output spaces correctly and more :(
When you do not supply an argument, the runtime error comes here int k = atoi(argv[1]); because argv[1] is null and atoi cannot accept null. You need to check that the user has supplied an argument be …
3
votes
Accepted
check50 not approving my code but it looks like it's working
The good news is: it looks like your ciphering algorithm is working. Yay. The bad news is you missed a important detail in the spec.
Notice the difference between what cs50 is expecting: "ciphertext …
3
votes
why does this code not ask for a string?
It will. If you do not supply any command line arguments. Try it.
Why is that? Recall from Week 2 > Section > Command Line Arguments
argc will always be at least 1, the name of the program.
When …
2
votes
Accepted
Why doesn't this work?
I don't know where you are on the "comfortable" spectrum, but I will assume that you're closer to "more" since you are trying this and you are using const. I hope I can explain it adequately. This sta …
2
votes
Accepted
Too much whitespace in vigenere.c, style50 error in pset2
Consider removing the typecasting, because it is essentially redundant. A char is a one-byte integer; the system does it's own internal "casting". Perhaps rewatch the caesar walkthrough. Starting arou …
2
votes
How to copy a string in pset2? strcpy results in segfault
The main reason for the seg fault is this string titleized_string = "";. As soon as you "set" titleized_string to "something-in-quotes" it becomes a constant. You cannot strcpy into a constant (it ha …
2
votes
Accepted
Pset2, Vigenere error "\ expected output, not a prompt for input" when I run check50
Your output does not match the spec. The spec says
Implement a program that encrypts messages using Vigenère’s cipher, per the below.
$ ./vigenere ABC
plaintext: HELLO
ciphertext …
2
votes
Accepted
Crypt() includes and compiling
It will work when constructed as in the man page. From man feature_test_macros:
NOTE: In order to be effective, a feature test macro must be defined before including any header files. This can …
2
votes
Accepted
Week 2 CRACK: Erratic behavior with NULL '\0' when printing combinations of letters
This is a textbook example of "undefined behaviour". It gives different results on different machines because, well, there's a bug and there is no way to predict when or how it will "work" or fail.
…