标签:col 读写 log close fclose title 文件读写 bsp stdio.h
目的:熟悉C的文件读写
环境:VC6.0++
补充:vc6.0库函数和头文件
代码:
1 #include <stdio.h> 2 #include <string.h> 3 4 void test_write(void) 5 { 6 FILE *fp = NULL; 7 char name[] = "mrsandstorm"; 8 9 fp = fopen("test.txt","w"); 10 11 if( fp == NULL) 12 { 13 printf("can‘t open the file"); 14 return; 15 } 16 17 if (fwrite(name, sizeof(char), strlen(name) ,fp) != strlen(name)) 18 { 19 printf("file write error\n"); 20 } 21 fclose(fp); 22 } 23 24 void main(void) 25 { 26 printf("start.\n"); 27 test_write(); 28 printf("end.\n"); 29 }
标签:col 读写 log close fclose title 文件读写 bsp stdio.h
原文地址:https://www.cnblogs.com/mrsandstorm/p/9229285.html