ChinaUnix.net
相关文章推荐:

ifstream 写文件

我使用ifstream 方式来实现文件并通过socket发送。现在请问两个问题: 1、socket的send和receive函数,一次发送和接收多少个字节最为合理,效率最高? 2、我如何定位当前文件所要读的位置,就是类似于fseed()的功能,能够分多次把文件读完,每次读一部分并发送。 比较急,在线等待,谢谢

by homegirl - C/C++ - 2006-09-26 17:30:07 阅读(2940) 回复(5)

相关讨论

ifstream inf; inf.open("/etc/appserver_2008/abc.dbf", ios::in | ios::binary); //inf.open(strDbfDataPath, ios::in | ios::binary); inf.read(pDbfBuffer, 60000); nQuoteFileLen = inf.gcount(); // 实际读取字节数 inf.close(); 红色的部分,无非一个是直接出了路径,还一个是从变量strDbfDataPath得到的路径,strDbfDataPath的类型是字符数组,而且打印出来的结果就是 /etc/a...

by michaelwu23 - C/C++ - 2008-06-13 13:34:33 阅读(1492) 回复(2)

char *cwd; char buf[PATH_MAX+1]; if ((cwd = getcwd(buf,PATH_MAX+1)) == NULL) {perror("pwd");return(-1);} string filename(cwd); filename.append("/test.config"); ifstream aliasfile(filename.c_str(),ios::nocreate); if (!aliasfile.good()) return(-1); int sockfd; string t_ip,t_nename; while (aliasfile >;>;t_...

by mills - C/C++ - 2003-09-17 14:49:32 阅读(460) 回复(1)

I have a TXT file with contents named test.txt as follow: This is a test 444444 333333 good by! I defined a ifstream variable named inFile and intialized with a string "test.txt", and I defined string outString and an ofstream variable named outFile with "output.txt" for initializing.I used the statements for coping the content of file test.txt into file output.txt as follow: inFile >;>; outStri...

by Tonney8888 - C/C++ - 2004-08-21 13:56:31 阅读(751) 回复(3)

Dear all: I am going to read a file "data.dat", its content is: [Code] 5 0 2 3 5 2 4 2 4 2 4 3 100 1 3 4 2 3 2 2 3 4 2 200 2 3 5 3 5 4 4 2 4 3 300 2 3 5 2 4 2 4 2 4 2 400 2 3 5 2 3 2 4 2 4 2 500 1 3 5 2 4 2 4 2 3 2 [/code] I want to sepearate the data into three part. The first one is [code] N=5; [/code] The second one is [code] key=[0 2 3 5 2 4 2 4 2 4 ...

by zhshqzyc - C/C++ - 2006-05-30 10:28:02 阅读(1746) 回复(8)

c++中 ifstream infile(file.txt)中,file.txt的默认路径是什么? EOF,EOL 文件结束符,行结束符分别是什么?

by eiik123456 - C/C++ - 2004-03-24 13:40:22 阅读(576) 回复(0)

#include #include int main(int argc, char* argv[]) {     std::ifstream ifs("f:/a.tmp");     assert(!ifs.fail());     char buf[1<<10];     ifs.read(buf, 600);     int n = ifs.tellg(); // 返回600     ifs._Read_s(buf, 600, 600);     n = ifs...

by jronald - C/C++ - 2009-10-02 14:29:07 阅读(1683) 回复(1)

[code] class doctmpl { ............... //声明 protected: char varflag; istream& is; ifstream ifs; ............... }; //这个函数正确 inline doctmpl::doctmpl(const string& fname, char chvar /* = '$' */) : ifs(fname.c_str()), is(ifs), varflag(chvar) { if ( !ifs.is_open() ) throw e_stream_err; } //open函数通不过 inline void doctmpl::open(const string& fname, char chvar) { ifs.open(fname.c_s...

by openX - C/C++ - 2005-09-27 09:00:10 阅读(2667) 回复(8)

非标准Standard C++,不支持getline

by silverwolf - C/C++ - 2004-02-16 09:23:40 阅读(3736) 回复(4)

First declare that this is a vc++ programming. Target:Accomplish the function of the copy in which from ofile.txt to tonney.txt file. Main implementation function: getline(). Coding as follow: //首先,实现从ofile.txt读取content,并把content保存到vector中去,return这个vector指针 void *CTestForTemplateOneDlg::OnGetStringLine() { UpdateData(); vector; *lines_of_text = 0; if( !this->;m_strFi...

by Tonney8888 - C/C++ - 2004-09-01 21:50:04 阅读(1583) 回复(0)

当执行到声明 “ifstream myifstream;”的时候出现这个 Program received signal SIGSEGV, Segmentation fault 系统是tru64unix5.1a,gcc的版本是 Configured with: /tantor/build/compaq-tru64/tru64-010710/alphaev56-dec-osf5.1/src/configure -v --host=alphaev56-dec-osf5.1 --build=alphaev56-dec-osf5.1 --prefix=/usr/cygnus/tru64-010710 --exec-prefix=/usr/cygnus/tru64-010710/H-alphaev56-dec-osf5.1 --target...

by ROXELL - C/C++ - 2004-06-05 22:25:16 阅读(965) 回复(2)