I try to create a text file, and with the help of a random letter generator (+ space, in order to get "words" of different lengths) write to this file a set of these letters. Separately, if I do, the file is created, the letters are generated, and together this cannot be done. You can explain why and set on the right path)
#include <cstdio> #include <cstdlib> #include <ctime> int main () { FILE * pFile; int val = 15*1024*1024; int i; srand(time(NULL)); unsigned char mass; for(i=0;i<30;++i) mass=(rand() % ('z'-'a'+1))+'a'; pFile = fopen ( "myf.txt" , "w" ); fwrite (mass , 1 , sizeof(val) , pFile ); fclose (pFile); } And another question: How can you fill the file with random letters with a space (so that you get "words") at 10MB?