I'm trying to write a number (randomly generated) to a file using a loop for some number of iterations. I have:
while (i++ < number) {
n = randno();
write(openFd, (char) n, sizeof(int));
}
The code compiles and runs. I can print 'n' to the screen, a file has been opened (code not shown), but there does not seem to be any data in the file when I try to open it using gedit
. I want a file with one very large number of a certain length. Where am I going wrong? Any help is appreciated.
By the way, what is a true random function
? Thank you.