2
votes
PSET 1 CASH stuck!
It looks you have written the body of various functions in the main() itself after function calls. These should go into the respective function definitions, generally places after the closing bracket ...
1
vote
Use of bool in PSET2
Your use of bool is correct, subject to the real problem. The function call isn't. I think your mind just got stuck using a pattern though. Look at the following code:
// Make sure every character ...
1
vote
Accepted
Function in C: How to create
The structure is simple. Pay attention to placement of curly braces and semicolons, specifically, where they are NOT.
#include statements
// The next line is a function signature to tell the ...
1
vote
Passing arrays into function in tideman
ranks[] means an array of values that has been named ranks; from the declaration, we can tell that the values will all be integers. Any time you see a name followed by square brackets in C-based ...
1
vote
Accepted
Week 2 Lecture - Functions - Valid Triangle
Just like the function printf, the valid_triangle function has to be called from within main in order to execute and produce results.
1
vote
Pset 3 runoff. Votes not updating, trying to understand the code sequencing
One problem I see:
In tabulate() for(int i = 0; i > voter_count; i++) I think you meant to write
i < voter_count because otherwise it will not enter the loop since your condition will turn out ...
1
vote
Accepted
CS50_Web ORMs,APIs_ lecture 4, classes4.py - Understanding Classes, Objects, Functions and Lists
passengers is a list of Passenger objects, therefore print(self.passengers) is printing a list of Passenger objects. This print(self.passengers.flight_id) would fail because self.passengers is a list ...
1
vote
Accepted
Adding a code block to perform operations on float
So you decided to make some functions, why not. The function definition would be like
return_type function_name(param1_type param1_name, param2_type param2_name, ...)
{
// body of the function
}
...
1
vote
Accepted
Trying to use functions to modify pset2 Caesar characters, get error: expression result unused for each function
It's exactly what it says. You have written an expression:
(character+key) % 26 + big_letters;
but you aren't setting the results of that expression to anything, hence it is unused.
You're doing ...
1
vote
Accepted
Pset3 Find - error in "helper" file - 'expected expression'
If you adjusted the indentation to match the curly braces, you'd realise that you put the else after the for loop, not one level higher after the if.
You don't need that outer if, as your for loop ...
1
vote
C : error non-void function search - value (find)
Having the errors multiply shouldn't necessarily be looked at as the code getting worse. Rather, the new errors should be analyzed for what they are. Sometimes an error masks other errors, other times,...
1
vote
Accepted
strstr function not working
Are you sure the problem is with strstr? Did you use debug50 or gdb to make sure everything is as you expect? Did you read the man page on fgets? Of particular interest:
fgets() reads in at ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
functions × 26pset1 × 5
cs50x × 4
pset3 × 3
javascript × 3
return × 3
pset2 × 2
c × 2
pset8 × 2
caesar × 2
cs50-ide × 2
runoff × 2
week2 × 2
boolean × 2
triangle × 2
python × 1
find × 1
final-project × 1
initials × 1
cash × 1
cs50-web-programming-with-python × 1
readability × 1
pset × 1
function × 1
tideman × 1