Grrr ... C ++文件I / O.
该死的.. FILE * fp比C ++文件i / o简单得多......
我只是没有得到它......真的!
>
filebuf,istream,ostream,ifstream,ofstream,iosteam ...
什么是f&(){(我用来做二进制文件i / o读写。
我需要能够读写,寻找并告诉
我使用哪个班级?????
沮丧..
Damn.. FILE *fp was just sooo much easier than C++ file i/o...
I just don''t get it.. really!
filebuf, istream, ostream, ifstream, ofstream, iosteam...
what the f&(){( do I use to do binary file i/o read and write.
I need to be able to read and write, seek and tell
which class do I use?????
frustrated..
" SpreadTooThin"写道:
"SpreadTooThin" writes:
该死的... FILE * fp比C ++文件i / o容易得多......
我只是没有得到它......真的!
filebuf,istream,ostream,ifstream,ofstream,iosteam ...
什么是f&(){(我用二进制文件进行i / o读写。
我需要能够读写,寻找和告诉
我使用哪个课程?????
Damn.. FILE *fp was just sooo much easier than C++ file i/o...
I just don''t get it.. really!
filebuf, istream, ostream, ifstream, ofstream, iosteam...
what the f&(){( do I use to do binary file i/o read and write.
I need to be able to read and write, seek and tell
which class do I use?????
使用ios :: binary作为打开文件的参数。
使用ifstr eam,tellg,seekg和read to read。
使用ofstream,tellp,seekp和write来写。
明智地用std ::盐游泳。
Use ios::binary as a parameter the file open.
Use ifstream, tellg, seekg and read to read.
Use ofstream, tellp, seekp, and write to write.
Salt judiciously with std:: until your head swims.
SpreadTooThin< bj ******** @ gmail.comwrites:
SpreadTooThin <bj********@gmail.comwrites:
>该死的.. FILE * fp比C ++文件i / o简单得多......
我只是没有得到它......真的!
>Damn.. FILE *fp was just sooo much easier than C++ file i/o...
I just don''t get it.. really!
http://www-h.eng.cam.ac.uk/help/tpl/...es/C++/io.html
*可能*帮助。
http://www-h.eng.cam.ac.uk/help/tpl/...es/C++/io.html
*might* help.
简单例子
#include< fstream>
#include< iostream>
#include< string>
#include< iomanip>
using namespace std;
int main(int ArgC,char * ArgV [])
{
// ----- -----------输入示例
// bin只是为了确保它在ms-windows和unix风格上的工作方式相同
(unix' 'es总是bin)
ifstream输入(" Filename.dat",ios_base :: binary);
if(!Input.is_open())
{
cerr<< __LINE__<< 看到错误 << endl;
throw" Error";
}
string Line;
while(getline(输入,线))
{
cout<< 读< <<线<< ">" << endl;
}
// -------------------输出示例
ofstream输出(" Filenameout.dat",ios_base :: binary);
if(!Output.is_open())
{
cerr<< __LINE__<< 看到错误 << endl;
throw"错误" ;;
}
//右边的右对齐空格右边填充为字符串
long Number = 10;
//以下写入文本
输出<< setiosflags(ios_base :: left)<< resetiosflags(
ios_base :: right)<< setw(20)<< setfill(''')<<数字<< endl;
//这将在大多数32位机器上写4个字节
//长时间写任意数据
Output.write(reinterpret_cast< char *>(& Number),sizeof(Number)); //
对面是Input.read
}
问候,Ron AF Greve
http://www.InformationSuperHighway.eu
" SpreadTooThin" < bj ******** @ gmail.com写信息
新闻:11 ********************** @ i13g2000prf.googlegr oups.com ...
Hi,
Simple example
#include <fstream>
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main( int ArgC, char *ArgV[] )
{
//----------------Input example
// bin just to make sure it works the same on ms-windows and unix flavors
(unix''es are always bin)
ifstream Input( "Filename.dat", ios_base::binary );
if( !Input.is_open() )
{
cerr << __LINE__ << "see an error" << endl;
throw "Error";
}
string Line;
while( getline( Input, Line ) )
{
cout << "Read <" << Line << ">" << endl;
}
//-------------------Output example
ofstream Output( "Filenameout.dat", ios_base::binary );
if( !Output.is_open() )
{
cerr << __LINE__ << "see an error" << endl;
throw "Error";
}
// Right left alligned space right padded long as string
long Number = 10;
// The following writes text
Output << setiosflags( ios_base::left ) << resetiosflags(
ios_base::right ) << setw( 20 ) << setfill( '' '' ) << Number << endl;
// This wil write 4 bytes on most 32 bit machines
// Write arbitrary data for instance long
Output.write( reinterpret_cast<char*>( &Number ), sizeof( Number ) ); //
Opposite is Input.read
}
Regards, Ron AF Greve
http://www.InformationSuperHighway.eu
"SpreadTooThin" <bj********@gmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
该死的..文件* fp比C ++文件i / o简单得多......
我只是没有得到它......真的!
filebuf,istream,ostream,ifstream,ofstream,iosteam ...
什么f&(){(我用来做二进制文件i / o读写。
我需要能够读写,寻找和告诉
我使用哪个班级?????
感到沮丧..
Damn.. FILE *fp was just sooo much easier than C++ file i/o...
I just don''t get it.. really!
filebuf, istream, ostream, ifstream, ofstream, iosteam...
what the f&(){( do I use to do binary file i/o read and write.
I need to be able to read and write, seek and tell
which class do I use?????
frustrated..