Hot answers tagged

7 votes
Accepted

undefined reference to `GetInt'

First, you'll need to install the cs50 library. Follow this link for more information about how you can install the cs50 library on Fedora! Second, you need to link the library binary file by ...
user avatar
  • 17.4k
2 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 ...
user avatar
  • 63
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 ...
user avatar
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 ...
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 ...
user avatar
1 vote

get_int invalid?

Did you #include <cs50.h>?
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 ...
user avatar
  • 5,172
1 vote
Accepted

Mario GetInt: When integer outside range entered, have to hit enter twice to get RETRY

Don't worry about the retry. Retry is only displayed when you enter something that is not a number, say a character like "space" or abc. But the problem with your code is that you put the printf ...
user avatar
  • 305
1 vote
Accepted

implicit declaration of function getint() is invalid in c99

That's GetInt(), not getint(). C is case sensitive.
user avatar
  • 3,316
1 vote
Accepted

int GetInt(void) and command line arguments

main is a special function. It's the starting point of a C program — it's called somehow magically when you execute the program from the terminal by typing its name in as follows ./programName main ...
user avatar
  • 17.4k
1 vote

Awkward behaviour of GetInt()

The only reason that GetInt() would return "Retry" is if it recieved a non-integer from standard input (ie, from your keyboard), as the definition says: /* * Reads a line of text from standard input ...
user avatar
  • 18.4k
1 vote
Accepted

Mario problem in IDE

The code is fine. It must be a bug with clang or aws. Try compiling it again.
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 ...
user avatar
  • 63.5k
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 ...
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 ...
user avatar
  • 20.7k
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 ...
user avatar
  • 63.5k
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 ...
user avatar
  • 63.5k
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 ...
user avatar
  • 18.4k
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, ...
user avatar
  • 20.7k
1 vote

get_int invalid?

i have used #include <cs50.h> header, but still facing the same problem. The cs50 complier continuously showing the following error message:- " implicit declaration of function 'GetInt' ...
user avatar
  • 11

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