generating random values

hello guys

it's been a long time, i have a problem, i need to generate random values, but these values need to be coordinates (x,y) i would like to hear ideas about how to do it?

Thanks a lot for any suggestion
Use rand().
rand() % number
number is the max number you want
Thanks for your answers but i think it is my fault not being more precisly!!!!

this is my problem

I generate a two dimension array static and then create ramdonly number but when i try to do the same thing using a dinamic array i got problems.. this is what i got

int Number_nodes;
int dimension;
int max_distance;
int* nodes;
int i,j;

printf("Please enter the number of nodes, dimension and maximum distance. ");
scanf("%d %d %d",&Number_nodes, &dimension, &max_distance);
nodes= (int *)malloc(sizeof(int)*Number_nodes);
nodes[j]=(int *)malloc(sizeof(int)*Number_nodes);

nodes[i][j]=rand() % dimension;;
printf("File: %d Columm: %d %d\n",i,j,nodes[i][j]);

Thanks beforehand for your help!!!!
Last edited on
use srand() to seed your random.
also, use code brackets so that

int main()

int main()

Last edited on
Topic archived. No new replies allowed.