October 22, 2024
Chicago 12, Melborne City, USA
C#

Is it possible to create a large array in C?


I have 16GB of RAM and this code

#include <stdio.h>
#define len 900000000

int phi[len];

int main() {
  for (int i = 2; i < len; i++) {
    phi[i] = i - 1;
  }
  phi[0] = 0;
  phi[1] = 1;
  for (int i = 2; i < len; i++) {
    for (int j = 2 * i; j < len; j += i) {
      phi[j] -= phi[i];
    }
  }
  return 0;
}

this code does not compile

error: unknown type size

Is there anything that can be done to make it compile without rewriting the code? I work on Windows 10.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video