0

I run the C program and I get the following errors.
4:20: error: too few arguments to function call, at least argument 'format' must be specified int x= get_int();
/usr/include/cs50.h:82:1: note: 'get_int' declared here int get_int(const char *format, ...)__attribute__((format(printf, 1, 2)));
7:20: error: too few arguments to function call, at least argument 'format' must be specified int x= get_int();
/usr/include/cs50.h:82:1: note: 'get_int' declared here int get_int(const char *format, ...) attribute((format(printf, 1, 2)));

Here's the code

#include <cs50.h>
int main(void){
    int x= get_int();
switch(x)
{
    int x= get_int();
    case1:
    printf("One!\n");
    break;
    case2:
    printf("Two!\n");
    break;
    case3:
    printf("Three!\n");
    break;
    default:
    printf("Sorry!\n");
}
}

I'm aware the CS50 manual says about get_string: #include <cs50.h>

char *get_string (const char *format, ...);

But, I'm still not sure if this information helps in my example.

1 Answer 1

1

In the current implementation of the functions of the header file cs50.h, we need at least one argument of the type char *, that is, a string, something similar to the function printf (), therefore to eliminate the error we can simply write something how:

int x = get_int ("Please, type an integer");
4
  • In other words, add a prompt as a parameter.
    – Cliff B
    Commented May 6, 2020 at 22:07
  • It worked but now I get the error: /tmp/ex1-c7c4bc.o: In function main': ex1.c:(.text+0x1b): undefined reference to get_int' clang-7: error: linker command failed with exit code 1 (use -v to see invocation) I tried typing -v and it says command not found
    – mikeli
    Commented May 7, 2020 at 17:19
  • If you are using the IDE use the make command, if not add -lcs50
    – MARS
    Commented May 7, 2020 at 21:17
  • thank you! Sorry, I didn't see that on time!
    – mikeli
    Commented May 8, 2020 at 0:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .