Robert S. Pratt
  • Member for 1 year
  • Last seen more than a month ago
Getting "non-void function does not return a value in all control paths"
Accepted answer
7 votes

It means that there is no default return value for your function outside of the for loop. You are assuming that loop will always run, but, what if an empty string ends up getting submitted? The ...

View answer
Lecture 2 Arrays
Accepted answer
2 votes

The error you are getting is not saying that you are passing a double instead of a float, but that a double is expected. You are passing average, which is not a variable but a function. Your prototype ...

View answer
why am i not returning a value for my function?
2 votes

We talked about this before. Take the return statement out of your loops. You only need to have a value returned after all of the function has been performed. You are getting this error because the ...

View answer
Caesar Error:Invalid operands to binary expression ('string' (aka 'char *') and 'int') int c = ((int)text + argv[1]) % 26
2 votes

You are missing a { immediately after your main declaration and before your for loop. This means the computer sees the declaration and then a bunch of code, but doesn't understand the code belongs to ...

View answer
Mario less, struggling with nested FOR loop
Accepted answer
2 votes

Don't stress yourself out too much with trying to understand everything, even after reading up on it--sometimes things only "click" after your brain stops thinking about it. Let's take a ...

View answer
A problem with my code in PSET 1 Mario less comfortable
Accepted answer
2 votes

The problem is in your nested for loop. It prints a space all the way up until i + j <= n - 1. Once this is no longer true, your program exits the loop. Let's look at this in a little more detail: ...

View answer
Choice of loops in C: Are the three loops exclusive or replaceable for a task
Accepted answer
1 votes

I think it is best to remember that each type of loop (and programming concept in general) is like a tool in your tool box. Just as there are many different types of hammers and screwdrivers, and you ...

View answer
Type int in scanf
Accepted answer
1 votes

When in doubt or you are sure you have done something correct but still receive errors, you should always check the the CS50 Man Pages to see what it says. In this case, it says that scanf needs a ...

View answer
PSET4 Recover error: incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *
Accepted answer
1 votes

You need to use double quotes, not single quotes. 'w' is understood by the compiler as the char w, while "w" is understood as "write-mode". (Remember that chars also have an ...

View answer
PSET6 - Readability. When I am running my program it is showing me this error again and again
Accepted answer
1 votes

length is a single value: an integer equal to len(user_input). You cannot iterate through a single value, so Python will throw an error for for i in length. You can either use a standard loop where ...

View answer
Plurality Clarification
Accepted answer
1 votes

You can edit whatever you need to in order to make the logic work so that the program produces the expected results. If in the end, the code you write produces the same logical output, it should be ...

View answer
Plurality starter code clarification
Accepted answer
1 votes

candidate is the datatype. It is a custom datatyoe (also called a "user-defined" datatype). The name of the variable is candidates plural. You will find the datatype defined either in the ...

View answer
How can I launch my final project from CS50ide to the internet as a public website of my own?
1 votes

You will need to use a hosting service (GitHub pages, GitLab pages, 1and1.com, GoDaddy.com, etc.) or host it yourself on your own machine (such as a Raspberry Pi, secondary computer, etc.), have/...

View answer
How do I change if/else if statements into a loop?
Accepted answer
1 votes

You are already half-way there. Your for loop does something for each iteration. Now, you want to do something inside that loop for each iteration. The answer is another for loop--a concept called &...

View answer
Indexing problem
Accepted answer
1 votes

I have tested your code, including the new code you've added in your edit, and your conditions work when the arithmetic is removed. This means changing capAlph[p] == text[i] - 'A' to capAlph[p] == ...

View answer
Why is an Array longer then the input?
Accepted answer
1 votes

So, in C, strings don't really exist in the same way that they do in other languages. A string is a char array. C also does not pass strings and arrays between functions, but pointers to the locations ...

View answer
How to solve no suitable constructor found for Class1(Class2)?
1 votes

This SE site is specifically for CS50 and its problems--according to the site/community rules, all questions should be related to CS50 courses and projects. You will have better success getting your ...

View answer
How to solve incompatible types: Name cannot be converted to String in java?
Accepted answer
1 votes

Edit with the new info regarding the required UML specifications: As I wrote in a comment below (but am transferring here as an answer), your name variable is part of your Name class. This class has ...

View answer
Problems with Lab4
Accepted answer
1 votes

The issue is that you are reading your header in a loop. This action only needs to be done once, which is why the exact size of the header is provided. By reading it in a loop, you are reading through ...

View answer
can someone translate this to human?
Accepted answer
1 votes

You are getting this error because not every path through your function returns a value. Most likely, the compiler sees that both of your loops have a return statement and expects the function itself ...

View answer
my terminal is not liking that I'm trying to pass a string into an int. Isnt there a way to force that?
Accepted answer
1 votes

You cannot force a string to an int. A string is an array of char values. An int is a single value. As you noted in a comment, you will need to iterate though the char array and convert each of the ...

View answer
error code "linker command failed" on custom function
Accepted answer
1 votes

You have declared your function incorrectly. It should not be within your main function. So, it should look like this: int main(void) { // code you want in the main function } int compute_score() ...

View answer
Program won't print out enciphered text
Accepted answer
1 votes

You have a logic error in your declaration of ciphertext. Take a look at how it is declared (it's type) and the type of plaintext. ;) This should hopefully make it clear why one seems to work with ...

View answer
what's going on here? I know there shouldn't be a semicolon after my main function but miss terminal wants one. why?
1 votes

You'll need to show your code for your main function to be point out the exact error, but you have a problem with your function declaration, so it thinks you are declaring a function prototype instead ...

View answer
Blur - I'm so close, but yet not 100%
Accepted answer
1 votes

I see two issues with your code. First, the following code is nested inside of your other for loops: for (int i - count_from_i; i < count_to_i; i++) { for (int j = count_from_j; j < ...

View answer
Imprecision during float subtraction in python
Accepted answer
1 votes

There is not really a mechanism to describe. Floats are only so precise, and so performing mathematical operations with them will result in some imprecision in results. I'll keep this discussion to ...

View answer
why is my terminal telling me a file doesn't exist when I'm looking at it in the file tree?
Accepted answer
1 votes

You keep having this problem because you don't always return to the directory where the file is made or moved to. Look to the left of the terminal line where you are working: the ~/ means your ...

View answer
What does "no rule to make target" mean in terminal?
Accepted answer
1 votes

You are in your home directory ~/ and that is not where list.c is located. It looks like list.c is located in ~/classwork. Whenever you get an issue like this, try running ls -a (-a flag adds hidden ...

View answer
why is my terminal freaking out? what did i do?
Accepted answer
1 votes

Ctrl+C will cancel whatever program the terminal is running and send you back to your directory. Without knowing what command threw you into the loop, I can't help further, but this should at least ...

View answer
ls isnt giving me a.out in the terminal like like i want it to. why?
Accepted answer
1 votes

In the image you provided, the pset1 directory in the directory tree to the left of the IDE is collapsed--notice how the arrow is pointing to the directory's folder and not down, as the arrow next to ...

View answer