随机写入一个文件一些字符

来源:互联网 发布:java ssh框架面试题 编辑:程序博客网 时间:2024/06/11 06:00
/ / w3.cpp:定义控制台应用程序的入口点/ /#包括<STDIO.H> #包括<stdlib.h>中的#include <TIME.H>int  main ( int  argc ,  char *  argv []) { srand (( unsigned ) time ( NULL )); char  b [] = { "ACGT" }; FILE *  pfile ; char  buf [ 2 ] = { '\0' };     pfile = fopen ( "d: \\ 123.txt" , "w+" ); for ( int  i = 0 ; i < 100000 ; i ++ ) { buf [ 0 ] = b [ rand () % 4 ]; buf [ 1 ] = '\0' ; fwrite ( buf , sizeof ( char ), 1 , pfile ); } fclose ( pfile ); return  0 ; }

0 0
原创粉丝点击