读书人

c语言操作资料

发布时间: 2012-10-08 19:54:56 作者: rapoo

c语言操作文件

有一些同事是做Java 的有人问我怎么用C语言

?

//============================================================================// Name        : HelloWorld.cpp// Author      : liuqing// Version     :// Copyright   : Your copyright notice// Description : C语言操作文件//============================================================================#include <iostream>#include <stdio.h>#include <stdlib.h>using namespace std;int main() {//定义文件指针FILE *fp;//定义输出字符char ch;cout << "Reading file...." << endl;//打开文件if ( ((fp = fopen("f:\\aa.txt","rt")) == NULL)){cout << "error open file f:\\aa.txt";}else{//根据文件指针操作文件while ( (ch = getc(fp)) != EOF){putchar(ch);}}//关闭文件fclose(fp);return 0;}
?

?

?

读书人网 >C语言

热点推荐