查看: 1044|回复: 2
|
APPEDN FILE
[复制链接]
|
|
我是用C++的,如果我要在一个text File里增加text....
我应该要怎样做?
#include<iostream>
#include <fstream>
int main(){
fstream infile("test.txt");
infile>>???;
??
??
??
??? |
|
|
|
|
|
|
|
发表于 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 ...
这个跟我找的一样 ....不过,问题解决了..... |
|
|
|
|
|
|
| |
本周最热论坛帖子
|