Hi, I am pretty new to C and having some trouble that seems pretty challenging to my limited knowledge and experience. Everytime I tried to execute any program containing any sort of randomization code, I get back this error message:"Segmentation fault (core dump). Here's an exemple of one of my codes
I have a hunch that it might be related to my system version (windows xp SP 3 / GCC 4.3.4 ) but I can't quite confirm. Please Help.Code://This program demontrates the use of the randomization concept. #include<stdio.h> main() { int iRandomNum = 0; srand(time()); iRandomNum = (rand() %4) + 1; printf("\nFortune Cookie - Chapter 3\n"); switch (iRandomNum) { case 1: printf("\nYou will meet a new friend today.\n"); break; case 2: printf("\nYou will enjoy a long and happy life.\n"); break; case 3: printf("\nOpportunity knocks softly, can you hear it?\n"); break; case 4: printf("\nYou'll be financially rewarded for your good deeds.\n"); break; } }



1Likes
LinkBack URL
About LinkBacks


