Hot answers tagged

4 votes

Submitting Source Code?

When you have completed the pset, and you have checked your program works correctly, using check50 you should go at the CS50 submit and upload the file you have written your code in, called the source ...
user avatar
  • 7,326
2 votes
Accepted

Error: use of undeclared identifier 'j'

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 ...
user avatar
  • 63.1k
2 votes

code doesn'work, please help

You seem to have made quite a few mistakes in your code. This is of course not unusual for someone who's just starting out, so let me point you in the right direction. You are reading the first reply ...
user avatar
  • 332
2 votes

make: *** No rule to make target 'cash'. Stop

You gotta change your directory to where cash.c is located. cd pset1
user avatar
1 vote

Does somebody explain %d, %s, etc

These characters are used as "wildcards" or placeholders. They are used in conjunction with something like printf(). Very basic example //declaring an int variable to a value of 5 int x = 5; ...
user avatar
1 vote
Accepted

Does somebody explain %d, %s, etc

printf formatting is a language unto itself. This document helped me a lot. Hope you find it useful.
user avatar
1 vote
Accepted

I have a problem regarding " Condition"

You cannot compare strings in C to compare strings you must use a function called strcmp()if I remember correctly it should be in the string.h so just #include <string.h> and you should be able ...
user avatar
  • 701
1 vote
Accepted

Trying to do pset 2, but it doesn't even accept my input. What am I doing wrong?

The problem lies here: for(int i = 0; i < keyL - 1; i++) { for(int j = i; j < keyL; j++) { if(key[i] == key[j]) return 0; } } When the loop runs the first time, ...
user avatar
  • 63.1k
1 vote
Accepted

how do i write pesudocode.txt for Mario? (less comfortable)

You make a new file by clicking the green plus sign at the top, next to where it says the name of the file you are currently on. On your keyboard, then do command shift S. It will give you options for ...
user avatar
  • 67
1 vote

Syntax Highlighting Error

Just a guess, did you open a new file that has yet to be named or saved? Assuming you're in the CS50 IDE, are you writing your code in a file with the .c extension? The IDE has to see that extension ...
user avatar
  • 63.1k
1 vote

Submitting Source Code?

This is how to submit on edx, I would assume that if you are taking the class in any other capacity there is a similar link. http://apps.cs50.edx.org/cs50x/2015/@/portal
user avatar
  • 111
1 vote

How do I unzip source code?

easy. unzip filename.zip For more info, on a command line, just type unzip with no parameters.
user avatar
  • 63.1k
1 vote

Why is the value 16,432 appearing, and why is it getting reduced each time I run the program?

Local variables are not initialised by default. The values you find there are the remains of other variables (or data related to function calls) that occupied that exact same location of the stack ...
user avatar
  • 20.7k
1 vote

pset6 - greedy doesn't print answer- just returns the input. Where have I gone wrong?

if n >= 0: break This breaks you out of the While loop, so your program simply ends if the user gives you a positive number.
user avatar
  • 18.3k
1 vote

Credit Card Test Confusion

Taking the first one through the example in the spec: 3 7 1 4 4 9 6 3 5 3 9 8 4 3 1 Okay, let’s multiply each of the underlined bold digits by 2 7*2 + 4*2 + 9*2 + 3*2 + 3*2 + 8*2 + 3*2 That ...
user avatar
1 vote

why doesnt this code print the number of bottles of water used? it only stops after prompting user for number of minutes

Right now your code is just printing m, bottles is only defined, it is never called. If you want to declare a variable, but not initialize it, int b; is what you would write. int b = b; assigns a new ...
user avatar
  • 1,223
1 vote

Problem with format codes

The short answer is that you're using the wrong format code. While you can cast the values and make it work, it would be easier to just use the correct code, %lu, for an unsigned long. google printf ...
user avatar
  • 63.1k
1 vote

Problem with format codes

It is because your Compiler warnings are ON. The return type of sizeof() function is size_t. It is System and Compiler dependant. May be if you Compiler your code on 32 bit machine, it will have ...
user avatar
  • 549
1 vote
Accepted

week7 lecture2 source code speller.php not found

From your first link choose Index in the Source Code pane (far right). Choose misspellings/. Click on download to the right of speller. It will open with a text editor (like notepad++). It's also in ...
user avatar
1 vote
Accepted

What's wrong with this code for the Caesar Cipher?

The problem lies with your use if isalpha() and islower(). Your code is: if (isalpha(encryptString[i]) == true) Surprisingly unintuitively, if the character is an alpha, this will NOT evaluate as a ...
user avatar
  • 63.1k
1 vote

Help with pset1 mario, I don't understand what's wrong with my code

Your loops mean that you don't print out the right number of # signs. Because your i starts of at 0, on the first pass j = 0 which equals i and so only one pass is printed. Therefore you need to ...
user avatar
1 vote

what is wrong in this program?

Reference50.cs50.net may help you- a list of a lot of C functions, and the header files they are in.
user avatar
  • 1,211

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