#include <the iostream> #include <stdio.h> #include <the fstream> the using namespace STD; int main () { the FILE * FP = the fopen ( " test.txt " , " WB " ); // for writing read way to create a binary file and returns the file pointer IF (fp == NULL) { printf ( " CAN not at The Open file test.txt \ the n-! " ); Exit ( 1 ); } the else { printf ( " at The file the Test. the Opened sucessfully TXT \ the n-! " ); } int CNT = 0 ; char S [ . 3 ] = " " ; // cycle playing table (GB2312-80) for ( int I = 0xB0 ; I <= 0xF7 ; I ++) { // the upper eight bits S [ 0 ] = ( char ) I; for ( int J = 0xA1 ; J <= 0xFE ; J ++) { // lower 8 bits S [ . 1 ] = ( char ) J; CNT ++ ; fprintf (FP, "S% \ n- " , S); } } fclose (FP); the printf ( " Total:% D \ n- " , CNT); // correct result: 6768 System ( " PAUSE " ); return 0 ; }
Reproduced in: https: //www.cnblogs.com/pcwl/archive/2012/08/20/2647049.html