Hello everyone,
I've been programming in Java for approx 1.5 years and am moving to C now for my CS degree. I have a book that I'm moving through pretty fast but am kind of stuck on a rand number problem which keeps giving me a segmentation fault error. Right now I'm stuck because this is an example in the book which is compiling and linking but not executing. I'm on Ubuntu 11.10 if it matters I think the book was designed for windows. Here is the block of code.
I've been googling all day and the only thing I can come up with is that it's an OS specific problem because it has something to do with a hardware error. I don't think that's what it is but that's what I've been seeing. Thanks a lot guysCode:#include<stdio.h> main(){ int iRandNum = 0; srand(time()); iRandNum = (rand() % 4) + 1; printf("%d", iRandNum); }



1Likes
LinkBack URL
About LinkBacks



