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.
1
vote
Accepted
Pset2 Substitution -- check50 "timed out while waiting for program to exit"
There are other combinations of (upper-case) letters whose sum of ascii values is 2015.
1
vote
Accepted
help with Caesar problem from Pset2
This declaration string ciphertext[text_length]; creates an array of strings. From the context it should be a char array, not a string array. Changing that will likely lead to cascading compile error …
0
votes
Accepted
help with debugging readability from Pset2
Suggest set a breakpoint in get_letters at if (isalpha(text[i]) == true) and see what happens next. If it is not what you expect, review the man page for the char "is" functions, expecially the functi …
1
vote
Accepted
PSET 2 - Substitution - incompatible integer to pointer conversion using strstr function
The compiler doesn't differentiate between int and char. char is essentially a subset of integers. I will venture a guess that 'A' does not in fact work (single-quotes makes it a char), whereas "A" do …
1
vote
PSet2, Substitution, Unexpected Output - Nested FOR loops producing repeat iterations
One problem is: after a letter is substituted, and text[i] is changed, the j loop continues and might substitute again, depending on the key. After substitution program should break out of the j loop. …
0
votes
Update to no-vowels: problem returning function result to main(): strange behaviour in CS50 ...
One "problem" is that leeted in the replace function is declared as a Variable Length Array (VLA)
The key takeaway for me:
...lifetime of a VLA ends when the declaration goes out of scope
Change th …
0
votes
Accepted
Segmentation error on isdigit function
The segfault is coming because there does not exist argv[1] at this line b = isdigit(argv[1][i]);
Wait what????
The function definition declares a string array with 1 element. The index of that elemen …
2
votes
CS50P - Error in pset2 (Coke)
From the spec:
Suppose that a machine sells bottles of Coca-Cola (Coke) for 50 cents and only accepts coins in these denominations: 25 cents, 10 cents, and 5 cents.
30 is an invalid entry.
See the f …
1
vote
Accepted
How to solve "error: expected expression" while doing Caesar.c
This doc shows the correct syntax for the typecast operator in C.
Syntax
( type-name ) expression
Typecasting is demonstrated in the lecture at around 1:03:00.
0
votes
Pset 2 ceaser problem
Which number is both less than 0 and greater than 9? No number would ever produce "true".
To test a value between 0 and 9, the conditional is:
if num >= 0 && num <= 9
1
vote
Accepted
How do I check that every character of an array is a digit and only print out the string if ...
Program doesn't know if all the characters in key are digits until after it has processed all of them. The "Success" message should come after the for loop is finished. And remember this hint from the …
0
votes
:( handles lack of key failed to execute program due to segmentation fault
The program is trying to use argv[1] here int l = strlen(argv[1]); before it knows whether argv[1] exists (if (argc != 2)).
1
vote
Pset2 Readability error with "else" statement
if/else is binary. true/false. An If cannot have two else clauses. It needs an else if to add additional conditions, as described here. [The page is for C++, but the lesson is valid in C]
0
votes
PSET2: Readability code giving wrong grades
Looks like l is trending high. It counts every character in the text except the terminating null byte (which never makes it into the loop anyway!). Check out man isalpha to get back on track. This ma …
0
votes
Accepted
Pset2 Readability. I am starting to do readbility and for some reason the code i wrote this ...
To see the whole picture, add text to the printf.
From man scanf re the %s directive:
s
Matches a sequence of non-white-space characters; the next pointer
must be a pointer to character array that is …