Hot answers tagged

2

Ahh I figured it out! Instead of using ~/pset1/hello/ $ go back to just the directory pset by using change directory ~/pset1/hello/ $ cd ~/pset1/ then add your ls command ~/pset1/ $ ls hello/ hello.c then compile ~/pset1/ $ clang hello.c adds the machine code to your directory and then you can execute! My only questions now is about the hello/ . ...


2

It's a simple problem and the same issue in all cases. The code is trying to do dollar % 25 BUT, dollar is a float, not an int. The modulo operator requires both operands to be integers. Modulo cannot be applied to a float. Maybe you meant to use owed instead? You'll need to declare owed before the do/while loop for it to stay in scope though. If this ...


2

The prototype and the actual function don't match. //Prototype void meow(void); ... void meow(int n) {... I'm surprised it even compiled. Both need to have int n


1

It's a very subtle "possible" error that valgrind detected. When I ran it with the small dictionary, I get this: ==224== Conditional jump or move depends on uninitialised value(s) ==224== at 0x401CB1: unload (dictionary.c:145) ==224== by 0x40175F: main (speller.c:152) ==224== Uninitialised value was created by a heap allocation ==224== at ...


1

The uninitialised value comes from load. Are you setting both members of the node in all cases? I don't see where you set your new node's next pointer in all cases.


1

The screen shot would be easier to read if larger, or simply pasted text. It says: cannot open file cash: Is a directory. If if the full path to the file being compiled should be pset1/cash/cache.c, but it is actually pset1/cash.c, the presence of a directory called 'cash' will cause that error. Try running 'pwd' and 'ls' yourself. If you see this: ~/pset1/ $...


1

Have you compiled the program locally? The compiler should complain about this strlen(champions) because champions is declared an int array here int champions[pair_count]


1

I found the mistake was in a space between %i\n and ", in the line printf("Grade %i\n ", (int) round(index)); The problem was solved when rewriting to: printf("Grade %i\n", (int) round(index));


1

When the type prefix is used, that's declaration. For example int cents;. The first error tells you that cents has been declared twice. (do not use int on subsequent instances of cents). "initialization" means the (declared) variable has been set to something. Compiler is complaining that dollars has been declared (ie float dollars) but not set to ...


1

Two problems: the semicolon after main() and the placement of the curly braces. The structure of a program should look like this: #include... //includes first int main(void) //note no semicolon here { // nothing between the main declaration line and the opening curly brace. // program code goes here } // closing curly brace to end main. ...


1

It happens some times. It is still in the substitution directory. If you are not sure then type cd in the terminal and then type cd pset2/substitution in the terminal. If this helps please check the tickmark.


1

It seems correct because it is. The 'expected expression' error is almost always because of misplaced, missing or extra curly braces or parentheses. Is it possible that you're editing one version of the source code and trying to make another version, or filename? Also, recommend that you run your code through style50 to clean up formatting a bit.


1

Sign out of the ide with this link: http://ide.cs50.io and close the tab/window. Next, sign completely out of github. Next, open a new tab/window and go to http://ide.cs50.io You should be prompted to sign in. Do so. Now try check50 again. If you still get that error, send an email to sysadmins@cs50.harvard.edu with your problem & details.


1

The parameter list one=one, wp=wp, u1=u1['id'] binds three values. The query UPDATE rankings SET TTTWins = TTTWins + :one, TotalWins = TotalWins + :one, points = points + wp WHERE userID = :u1 has two (distinct) named parameters.


1

I fixed it for you. #include <cs50.h> int main(void) { //Prompt for the height of the pyramid int height; do { //Takes input, assigns it to height and prints it height = get_int("Pick a positive integer between 1 and 8:"); printf("Height: %d\n", height); } while (height<1 || height>8)...


1

string name = get_string ("What is your name?\n"); This line needs to be inside the main function. It also needs to be before printf("hello, %s\n", name); this line, since you can't use the name variable until after it exists.


1

You did use an undeclared identifier j in the second for loop. It isn't created until and only inside the following 3rd for loop. The compiler never lies. It might mislead on occasion, but it never lies.


1

You have to add } at the end, and in the middle before float l = 100 / words * letters; to close out the for loop.


1

Consider the for loop in your vote() function: It compares the candidate name with the name introduced by the voter. In the very first pass (i = 0) what happens when the candidate name and the name introduced are not the same?


Only top voted, non community-wiki answers of a minimum length are eligible