I am trying to produce a program which produces a random array of numbers but I am running into a problem in that when the array becomes even a little large, say 10x10, I get the Bus Error or Segmentation Fault (I think I still get the error with even smaller arrays). Can someone point out what I am doing wrong? It's probably really stupid, but I am really new to this so I make a lot of stupid mistakes :$
Here's my code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main ( void )
{
int i, j, *randno[i][j], arraysize;
arraysize = 100;
srand ( (unsigned)time ( NULL ) );
for(i = 0; i < 10000; i++)
{
randno[i][j] = malloc(arraysize * sizeof(int));
}
for(i=0;i<10;i++)
{
for (j=0;j<10;j++)
{
randno[i][j] = rand() / ( RAND_MAX / 100 + 1 );
printf ( "random number = %d\n", randno[i][j] );
}
}
return 0;
}
I'm also fairly unsure with malloc so if anyone can show what I am doing wrong there it would be greatly appreciated!!!