Home > Back-end > I want to ask me why can't write the generated random number in the text? Online please! Thanks
I want to ask me why can't write the generated random number in the text? Online please! Thanks
Time:10-08
# include & lt; Stdio. H> # include & lt; Cstdlib> # include & lt; Time. H> Int main () { The FILE * fp. Fp=fopen (" random number. TXT ", "w +"); If (fp==NULL)//determine if the File pointer is empty {printf (" the File always open! "); exit(0); } int n; Int d [100]; int a; srand(time(NULL)); For (n=0; N & lt; 100; N++) [n] {d=1 + rand () % 100; Printf (" random number between 1 and 100: % d \ n ", 1 + rand () % 100); } The fclose (fp); Int I=1; While (I=1) {printf (" please enter a number to query (exit) input - 1: \ n "); scanf("%d",& A); {the for (n=0; n<100; N++) {if (d==a) [n] {printf (" have the data of the random number \ n "); break; }} printf (" random number without this data \ n "); } } return 0;
}
CodePudding user response:
From the beginning to the end did not see the write file operations Fprintf is written to the file