Hot answers tagged

5 votes
Accepted

Week 1 compiling String.c using clang instead of make

The make utility actually calls the clang compiler with special options that can be set for a project. When I run make in the ide it actually runs the following: clang -fsanitize=integer -fsanitize=...
robert_x44's user avatar
3 votes

How should I take notes for the lectures?

you don't have to do that because there are already notes for each lecture in a PDF form which you can find under each lecture video in edX. you may still want to take your own notes (maybe even on ...
2 votes
Accepted

Can't use get_long_long();

Does cs50.h have a function called get_long_long?. There is no function by that name listed in the CS50 Reference. And notice this from the spec: Now, get_long itself will reject hyphens (and more) ...
DinoCoderSaurus's user avatar
1 vote

Cs50 week 1 problem (make: *** [ ] Error 1)

Looks like an issue with the environment setup. I suggest you repeat all the steps outlined in the course on setting up the cs50 IDE.
Cliff B's user avatar
  • 68.1k
1 vote
Accepted

Can't seem to get total number of years to print properly in Lab 1

I see two serious problems here. First, the print statement is inside the for loop, so you're going to print something on every pass through the loop, or nothing at all if the loop doesn't execute. ...
Cliff B's user avatar
  • 68.1k
1 vote

problem with credit with this numbers (369421438430814 & 5673598276138003)

I think you entered the wrong values when determining whether the credit card is Amex, Visa, or MasterCard. For Mastercard, you typed in (credit_helper <= 56 && credit_helper >= 51). Try ...
Ava's user avatar
  • 11
1 vote
Accepted

Week 1 Credit; Not Creating Variable

The program is stuck in an infinite loop. Look at the while loop setup: while(credit_number >= 0) // runs the loop until the credit card number is l { i = credit_number % 10; credit_number = ...
Cliff B's user avatar
  • 68.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 ...
mkg15's user avatar
  • 67
1 vote

Else If Boolean Statements of Equality In the Case of Complex Numbers

That example doesn't say what data type x and y are, but generally you can assume that numerical variables are real numbers in programming, unless specified otherwise. There is a way to work with ...
Llenk's user avatar
  • 744
1 vote
Accepted

Transform function into a loop or similar

Its good that you're thinking about how to make the code more efficient. Kudos to you! Yes, repeating code is a red flag that things can be simplified. But here, the code is very similar but not the ...
Cliff B's user avatar
  • 68.1k
1 vote

Week 1 cash.c assignment: How can I get a variable to mutate as it gets operated on?

About the first error in line 10 , you cant declare a vatiable twice , you can only assign it more than once , so you need to delete the float type declaration which is inside the do while loop. When ...
K. Mamdouh's user avatar
1 vote
Accepted

get_int variable in mario causing errors

It's an issue called variable scope, something that will be explained later. Simply put, a variable only exists within the surrounding pair of curly braces where it is created. In Prof. Malan's ...
Cliff B's user avatar
  • 68.1k
1 vote
Accepted

Week 1: get_int & get_string errors

Solved! I ran "update50" in the terminal twice, and after the second time a prompt came up that told me I'm currently running "pip 9.0.1" and there is an update available for "pip 10.0.1", and told ...
Xia Liu's user avatar
  • 19
1 vote

Week 1: get_int & get_string errors

Your line numbers in code and in the error messages don't match, are off by one, so I'd guess you forgot to save, or compiled something else (another file, maybe of the same name in a different ...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

Switch(c) undeclared identifier

Simply put, c doesn't exist because it was never declared, and no value has been assigned to it. I could explain in detail, but the following site has already done it very nicely, including an ...
Cliff B's user avatar
  • 68.1k
1 vote

Can't compile adder from week 1

It's a syntax error. A comma is missing before the z in line 11.
Cliff B's user avatar
  • 68.1k
1 vote

week 1 string.c errors

Be sure to save before making your program!
kzidane's user avatar
  • 17.6k
1 vote

Last program from the first half of the lecture in week one?

Follow the link in the source code to the ioccc page. Follow some of the links to find out what it's all about. It's very cool. Then search the original page for "thad" (it's a winning entry from 2000)...
DinoCoderSaurus's user avatar
1 vote
Accepted

Why does PrintName return void?

Good question. There is no requirement to capture a return value. Just because a function returns a value doesn't mean that the calling code needs to do anything with it. For many functions, like ...
Cliff B's user avatar
  • 68.1k
1 vote

why is no "\n" needed after GetString?

When you run this program, you indicate to the computer that you are finished entering your name by doing something. That "something" is where the new line in question comes from.
DinoCoderSaurus's user avatar
1 vote
Accepted

CS50 Appliance compiling error!

Say you have written a program named example.c First you compile your program like so make example Then you run it like so ./example I tell you these because I see you have tried many times to do ...
ChrisG's user avatar
  • 7,366
1 vote
Accepted

Week 1 - Conditions - error expression result unused (expect ; at end of if else)

The if/else if/else conditions are used in the following way: Single condition if (condition) { // code to execute } Double condition if (condition) { // code to execute } else { // ...
ChrisG's user avatar
  • 7,366
1 vote

Week 1 - Conditions - error expression result unused (expect ; at end of if else)

else is your last resort kind of command its like if this then { do this } or else if this then { do that } and finally when you cant think of any other condition you say you know what MR ...
Muneeb Hussain's user avatar

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