0

okay, so I wrote a program in Perl to find prime numbers and, when learning C, I decided to translate it into C. The thing is that...well...it doesn't work. No matter what I do, I get the same message when I say ./primes.c at the terminal: Segmentation fault. I know what this is, but I just can't put my finger on where it came from in my program. It would be much appreciated if anyone could figure this out for me, or help me to find it.

```
#include <stdio.h>
int main() {
int maxprimes;
int count = 1;
int value = 1;
int primes[maxprimes];
int composite;
int i = 1;
int j;
printf ("How many primes? ");
scanf ("%d", &maxprimes);
printf ("2 is prime\n");
primes[0] = 2;
while (count < maxprimes){
composite = 0;
value += 2;
for (j = 1 ; j < maxprimes ; j++) {
if (value % primes[j] == 0) {
composite = 1;
break;
}
}
if (composite = 0){
printf ("%d is prime", value);
primes[j] = value;
count += 1;
j++;
}
}
}
```

To explain the code a little, it's based on a Sieve of Eratosthenes algorithm, that's what the array is for. It's also probably the source of the segfault (the array, that is)