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 ...
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 ...
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 ...
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 ...
1
vote
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 ...
1
vote
Accepted
Mario problem in IDE
The code is fine. It must be a bug with clang or aws. Try compiling it again.
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
getint × 26pset1 × 6
mario × 3
cs50.h × 3
c × 2
error × 2
cs50-ide × 2
mario.less × 2
water × 2
do-while × 2
cs50x × 1
greedy × 1
function × 1
compilation-error × 1
week1 × 1
ide × 1
printf × 1
update50 × 1
command-line-arguments × 1
cs50-library × 1
water.c × 1
int × 1
getstring × 1
while-loop × 1
conditions × 1