佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1044|回复: 2

APPEDN FILE

[复制链接]
发表于 21-6-2007 02:45 PM | 显示全部楼层 |阅读模式
我是用C++的,如果我要在一个text File里增加text....
我应该要怎样做?

#include<iostream>
#include <fstream>

int main(){
fstream infile("test.txt");
infile>>???;
??
??
??
???
回复

使用道具 举报


ADVERTISEMENT

发表于 22-6-2007 09:56 AM | 显示全部楼层
不知这个范例能否帮到你:

#include <fstream>
#include <iostream>

using namespace std;

int main()
{
  char str[10];

  //Creates an instance of ofstream, and opens example.txt
  ofstream a_file ( "example.txt" );
  // Outputs to example.txt through a_file
  a_file<<"This text will now be inside of example.txt";
  // Close the file stream explicitly
  a_file.close();
  //Opens for reading the file
  ifstream b_file ( "example.txt" );
  //Reads one string from the file
  b_file>> str;
  //Should output 'this'
  cout<< str <<"\n";
  cin.get();    // wait for a keypress
  // b_file is closed implicitly here
}
回复

使用道具 举报

 楼主| 发表于 22-6-2007 11:06 PM | 显示全部楼层
原帖由 檞寄生 于 22-6-2007 09:56 AM 发表
不知这个范例能否帮到你:

#include <fstream>
#include <iostream>

using namespace std;

int main()
{
  char str;

  //Creates an instance of ofstream, and opens example.tx ...

这个跟我找的一样 ....不过,问题解决了.....
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 8-9-2025 08:38 PM , Processed in 0.107672 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表