'Initializer element is not a compile-time constant' when assigning a variable

86 Views Asked by At

I'm trying to run this code but on the terminal it says 'initializer element is not a compile-time constant:

enter image description here

#include <cs50.h>
#include <stdio.h>
int main(void)
int i = get_int ('first population: ')
int j = get_int ('second population: ')
1

There are 1 best solutions below

0
Jabberwocky On BEST ANSWER

Your code is wrong. Read closely the early chapters of your learning material.

  • you didn't put ;s at the end of your statements
  • your main function's body is not enclosed within {}
  • Your strings are not enclosed within "".

You want this:

#include <cs50.h>
#include <stdio.h>

int main(void)
{
  int i = get_int ("first population: ");
  int j = get_int ("second population: ");
  ...
  more code
  ...
}