Hey everyone,
Here's another problem I encountered:
when I write this: (This is a beginning of a "guess a number game")
it returns a segmentation fault. I tested multiple instances, and what I observed is, whenever I define a variable as (rand() % 10) + 1 following srand(time()) it doesn't work and I'm not sure why.Code:#include <stdio.h> main() { int iRandomNum = 0; int iResponse = 0; srand(time()); iRandomNum = (rand() % 10) + 1; ...
This however works:
The first code snippet is provided by the book "C programming for the absolute beginner"Code:#include <stdio.h> main() { srand(time()); printf("\n%d\n", (rand() % 8) + 1); }
Thanks for all the help