I'm writing a program that produces a unique sequence of random integers. It will ask the user for how many rows of random numbers they want to display, and the program will print a table of random numbers. The professor suggested using the srand()
and time(NULL)
functions in this program to make it work.
I've tried implementing the srand
and time
functions, but I haven't had any success. I've also tried writing a while statement but that hasn't been working out.
Code
int rows;
int main() {
// Use srand() function to generate random numbers and print the rows that the user specified
srand(time(NULL));
//int rows;
//int minRows = 0;
//int maxRows = 15;
printf("Please enter the number of rows you would like: ");
scanf("%d", rows);
while(rows<15) {
printf("%d", rows);
}
return 0;
} //class main
I expect this program to print out the rows of random integers that the user specifies, but instead I get a 'Segmentation fault (core dumped)' error after I try inputting the number of rows that I'd like.