首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

c语言操作资料

2012-10-08 
c语言操作文件有一些同事是做Java 的有人问我怎么用C语言?//

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;}
?

?

?

热点排行