您的位置:首页 > 编程语言 > C语言/C++

C++中对文件进行读写操作

2008-01-03 12:06 405 查看
#include "stdafx.h"
#include
#include
#include
using namespace std;
//从键盘上读取字符的函数
void read_save(){
 char c[80];
 ofstream outfile("f1.dat");       //以输出方工打开文件
 if(!outfile){
  cerr<<"open error!"<=65&&c[i]<=90||c[i]>=97&&c[i]<=122){      //保证输入的字符是字符
   outfile.put(c[i]);                            //将字母字符存入磁盘文件
   cout<=97)
   ch=ch-32;
  outfile.put(ch);
  cout<
int main(){
 read_save();
 creat_data();
 system("pause");
 return 0;


#include "stdafx.h"
#include
#include
#include
void read_save();
void creat_data();
using namespace std;
int main(){
 read_save();
 creat_data();
 system("pause");
 return 0;
}
//从键盘上读取字符的函数
void read_save(){
 char c[80];
 ofstream outfile("f1.dat");     //以输出方工打开文件
 if(!outfile){
  cerr<<"open error!"<=65&&c[i]<=90||c[i]>=97&&c[i]<=122){      //保证输入的字符是字符
   outfile.put(c[i]);                            //将字母字符存入磁盘文件
   cout<=97)
   ch=ch-32;
  outfile.put(ch);
  cout<

        C:/Symbian/8.0a/S60_2nd_FP2_SC/Projects/TestArray项目目录下会生成f1.dat,f3.dat文件,并且里面保存有每次程序运行时从console输入的字符.

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1475773
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: