/* * ===================================================================================== * * 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 ---------- */