/* * ===================================================================================== * * Filename: file.cpp * * Description: test for file * * Version: 1.0 * Created: 2010/1/19 17:56:07 * Revision: none * Compiler: gcc * * Author: bird * Company: nbut * * ===================================================================================== */ #include <stdio.h> #include <stdlib.h> int main ( int argc, char *argv[] ) { FILE * fp; if((fp=fopen("f1.txt","w"))==NULL){ printf ( "Can not open the file/n" ); exit(0); } fprintf ( fp,"%s","Hello World!/n" ); if(fclose(fp)){ printf ( "Can not close the file/n" ); exit(0); } return EXIT_SUCCESS; } /* ---------- end of function main ---------- */
file for hello world!
C语言文件操作示例
本文介绍了一个使用C语言进行文件操作的简单示例。该示例演示了如何创建一个文本文件并写入内容,包括打开文件、写入字符串及关闭文件等基本步骤。

被折叠的 条评论
为什么被折叠?



