Skip to main content
4 votes
Accepted

Difference between scanf and get_int

As you will discover later on during the course, get_int() is part of the cs50 library "cs50.h" which is not used in the real world, except in the course. To ease the apprenticeship, David ...
Guyyom's user avatar
  • 83
2 votes

get_int invalid?

implicit declaration of function 'GetInt' is invalid in C99 Though daunting, the compiler makes it very clear - your code implies that you want to use GetInt, but you instead use get_int(). I have ...
SuperNovaCoder's user avatar
2 votes

GetInt + sscanf -- why doesn't it accept only characters?

Good catch. Actually, c will never be populated with this command if (sscanf(line, " %i %c", &n, &c) == 1). It is a matching failure. From man sscanf: A conversion specification, which ...
DinoCoderSaurus's user avatar
1 vote
Accepted

What is the problem with my get_int for the lab 1 question population in C?

That program will end if a value greater than 8 is entered for x. The return x; returns from the main function, which is to say program ends. Ditto the return y;. return is the statement that ends a ...
DinoCoderSaurus's user avatar
1 vote

get_int invalid?

Did you #include <cs50.h>?
Steve Bunting's user avatar
1 vote

Can't get the do-while loop to work in pset1

You lack the main function, all console programs must have a main function: int main(void) { some code } The error is surely because the compiler thinks that you are going to define or declare a ...
MARS's user avatar
  • 5,179
1 vote
Accepted

Mario problem in IDE

The code is fine. It must be a bug with clang or aws. Try compiling it again.
IrishBumfuzzle's user avatar
1 vote
Accepted

Why is condition being ignored?

The problem is that the function get_pyramid_steps is never called by anything in main. It might as well not be there. If this answers your question, please click on the check mark. Let's keep up on ...
Cliff B's user avatar
  • 69.2k
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
  • 21k
1 vote
Accepted

I have a GetInt Function issue (Pset1)

The GetInt() function has been deprecated (deleted, last year?) and replaced with the more robust function get_int(). The new getint() function can be given a string as a parameter and it will print ...
Cliff B's user avatar
  • 69.2k
1 vote
Accepted

pset1 - CS50 directory not found for ./integer. Keep getting bash error - help?

Simply put, the file integer, the executable file, doesn't exist. Only the source code file integer.c exists. You need to make integer first, in order to compile the source code and produce the ...
Cliff B's user avatar
  • 69.2k
1 vote
Accepted

Pset1 Water Issue, reprompting with "Retry: " for Non-integers, and "Minutes: " for negative integers

what you are seeing is a side effect of how get_int works. If you have something like: int num; do { printf("Number: "); num = get_int(); } while (num < 0); And run it, you will see this ...
curiouskiwi's user avatar
  • 18.7k
1 vote
Accepted

Functions outside Cs50.h

As one can see on https://github.com/cs50/libcs50/tree/master/src those contain quite some code to keep you from messing up and provide a nice user interface. The simplest alternative would be scanf, ...
Blauelf's user avatar
  • 21k

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