0

I used the CS50 IDE for C on cloud9. When I run the program I get the errors

3:8: warning: **implicit declaration of function 'GetInt' is invalid in C99 [-Wimplicit-function-declaration] int x= GetInt();**<br /> 

3:8: error: **initializer element is not a compile-time constant int x= GetInt();**<br /> 

4:1: error: **expected identifier or '('switch(x)** 

Here's the code in C

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

Along with GetInt being updated to get_int, where is the following structure?

int main(void)
{
    //all the program code
}

This is not a complete program and the compiler thinks that you're trying to declare a bunch of globals using runtime vars.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

3
  • I don't have the original errors. But now I have new error messages < /br>4:16: error: too few arguments to function call, at least argument 'format' must be specified int x= get_int();</code><br /> /usr/include/cs50.h:82:1: note: 'get_int' declared here int get_int(const char *format, ...) __attribute__((format(printf, 1, 2)));<br /> 7:20: error: too few arguments to function call, at least argument 'format' must be specified int x= get_int(); <br /> /usr/include/cs50.h:82:1: note: 'get_int' declared here int get_int(const char *format, ...) __attribute__((format(printf, 1, 2))); – mikeli May 6 '20 at 17:41
  • New problems deserve a new question! ;-) – Cliff B May 6 '20 at 17:59
  • thank you loads! :) – mikeli May 6 '20 at 18:19

You must log in to answer this question.

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