Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

malloc issue

Name: Anonymous 2007-12-30 18:19

int *array;
array=malloc(1000001*sizeof(int));
int j=1;
for(j=1;j<=1000000;j++)
{
  array[j]=j;
}

Why am I getting an segfault error? What could I do (aside of reading SICP of course)?

Name: Anonymous 2007-12-30 18:56

I don't know.

Name: Anonymous 2007-12-30 19:24

Because your machine has only 4.000.000 Bytes RAM?

Name: Anonymous 2007-12-30 19:28

Because you write past the end of the array.

Name: Anonymous 2007-12-30 19:33

Read man valgrind

Name: Anonymous 2007-12-30 20:26

Read man "check your fucking return values"

Name: Anonymous 2009-03-18 3:03

The word pirahna, is all I can think of that rhymes with marijuana

Marijuana MUST be legalized.

Name: Anonymous 2009-08-16 22:41

Lain.

Name: Anonymous 2011-02-03 1:27

Name: Anonymous 2011-02-04 16:00


Don't change these.
Name: Email:
Entire Thread Thread List