C++ C++;文件读取使用
想向我的控制器添加一些I/O文本文件操作。要记录我选择的参数,请执行以下操作:C++ C++;文件读取使用,c++,text,c++builder,C++,Text,C++builder,想向我的控制器添加一些I/O文本文件操作。要记录我选择的参数,请执行以下操作: if ( FileExists("plik.txt") == true ) { int text_file = FileOpen("text_file.txt", fmOpenWrite); FileWrite(text_file, IntToStr(index_freq).c_str(),2); FileWrite(text_file,"\r\n",strlen("\r\n
if ( FileExists("plik.txt") == true )
{
int text_file = FileOpen("text_file.txt", fmOpenWrite);
FileWrite(text_file, IntToStr(index_freq).c_str(),2);
FileWrite(text_file,"\r\n",strlen("\r\n"));
}
但是你能在这个例子中告诉我如何使用FileRead吗?我知道模式是
FileRead(iFileHandle, &dRadius, sizeof(double));
但不能完全符合我的例子。写入文件的数据在一列中有1或2个字符长,在另一列中有一个字符长
提前感谢您的帮助为什么不使用iostream
std::ofstream ofs ("text_file.txt", std::ofstream::out);
ofs << index_freq <<std::endl;
ofs.close();
std::ofstreamofs(“text_file.txt”,std::ofstream::out);
ofs为什么不使用iostream
std::ofstream ofs ("text_file.txt", std::ofstream::out);
ofs << index_freq <<std::endl;
ofs.close();
std::ofstreamofs(“text_file.txt”,std::ofstream::out);
ofs为什么不使用iostream
std::ofstream ofs ("text_file.txt", std::ofstream::out);
ofs << index_freq <<std::endl;
ofs.close();
std::ofstreamofs(“text_file.txt”,std::ofstream::out);
ofs为什么不使用iostream
std::ofstream ofs ("text_file.txt", std::ofstream::out);
ofs << index_freq <<std::endl;
ofs.close();
std::ofstreamofs(“text_file.txt”,std::ofstream::out);
ofs由于文本行的长度可变,因此必须一次读取文件1个字符,直到找到换行符。对于这种I/O,最好使用TStringList
或TStreamReader
对象TStringList
将加载整个文件并为您分析换行符TStreamReader
有一个ReadLine()
方法,因此您可以一次读取一行文件。这两个类都在类中声明。hpp
由于文本行的长度可变,因此必须一次读取文件1个字符,直到找到换行符。对于这种I/O,最好使用TStringList
或TStreamReader
对象TStringList
将加载整个文件并为您分析换行符TStreamReader
有一个ReadLine()
方法,因此您可以一次读取一行文件。这两个类都在类中声明。hpp
由于文本行的长度可变,因此必须一次读取文件1个字符,直到找到换行符。对于这种I/O,最好使用TStringList
或TStreamReader
对象TStringList
将加载整个文件并为您分析换行符TStreamReader
有一个ReadLine()
方法,因此您可以一次读取一行文件。这两个类都在类中声明。hpp
由于文本行的长度可变,因此必须一次读取文件1个字符,直到找到换行符。对于这种I/O,最好使用TStringList
或TStreamReader
对象TStringList
将加载整个文件并为您分析换行符TStreamReader
有一个ReadLine()
方法,因此您可以一次读取一行文件。这两个类都在classes.hpp
中声明