ChinaUnix.net
相关文章推荐:

vc fstream 二进制

请问各位,vc里怎么存储进制文件啊,谢谢帮忙

by huaidanxieweide - 其他UNIX - 2006-08-17 08:01:04 阅读(1743) 回复(0)

相关讨论

#include "iostream.h" char *s = "你好,世界"; void unicode2hex(char * s){ while(*s){ printf("0x%x ",*s++); } } 本来想像这样写,但是好像是错的。 [ 本帖最后由 aobai 于 2008-10-16 17:26 编辑 ]

by aobai - C/C++ - 2008-10-16 17:20:46 阅读(1784) 回复(3)

以读写方式打开一个文件,刚开始可以往里卖弄写内容,用get读几个字符后,再往里写就写不进去了,怎么回事啊,难道读写不能同时进行?

by boldeagle - C/C++ - 2009-09-01 09:37:55 阅读(1126) 回复(3)

要用一个文件作为配置文件,比如config.txt,内容: ip: 10.0.0.111 port: 2222 现在要写程序,读取和修改配置参数。 如果用fstream来实现的话。读入好办,用>> 就可以了。但是修改有点麻烦。比如读入string 10.0.0.111后,怎样修改这个字串呢?初步的想法是写指针(用seekp())回退size()个位置,然后再写。可是有个问题,后写的字串长度可能超过原来字串长度,造成缓冲区溢出。这样需要把原来的字串留一些空格,保证最大情况...

by wishel - C/C++ - 2008-10-21 10:26:53 阅读(1164) 回复(6)

使用stl,就意味着告别熟悉的c-style编程方式,对文件的处理也毫不例外. fstream可以用来对文件进行处理,它象对待数据流一样对待文件. 以下给出一个例子.关键是事先要创建fstream.out文件,哪怕是个空文件,也要先创建.因为fstream不会为你创建. #include #include int main ( ) { using namespace std; // create a bi-directional fstream object fstream inout("fstream.out"); // output c...

by pearma - HP文档中心 - 2005-04-05 16:57:27 阅读(935) 回复(0)

如果是如下代码: [code] fstream sfs; sfs.open("test.txt"); [/code] test.txt文件原来是没有的,像上面的这段代码就没有新生成test.txt文件。 把代码改成: [code] ofstream sfs; sfs.open("test.txt"); [/code] 就可以了,怎么回事啊

by joyue - C/C++ - 2007-03-12 15:38:25 阅读(992) 回复(2)

class A{ fstream fout; } class B{ setF( ? ){ fout = ?} fstream fout; } 要求将A中的fout传送给B中的fout.

by wys0436 - C/C++ - 2007-01-10 14:23:45 阅读(2402) 回复(14)

什么时候需要调用它? 调用它会产生什么结果? 希望解释的详细些。 谢谢!!

by vaqeteart - C/C++ - 2007-10-26 18:28:17 阅读(5149) 回复(8)

以下两段代码 代码一 [code] int main() { fstream file; file.close(); file.open( "test" , std::ios_base::out ); file<<"adsfasf"; file.close(); system( "Pause" ); return 0; } [/code] 代码 [code] #include <fstream> int main() { fstream file; file.open( "test" , std::ios_base::out ); file.close(); file.open( "test2" , std::ios_base::out ); file<<"adsfasf"; file.close(); system( ...

by zzdts - C/C++ - 2007-06-10 01:21:30 阅读(1777) 回复(5)

ifsteam ifs("aa.txt"); string aa; while(ifs>>aa) {} ..... 这样默认是以空格隔开的,现在想用别的字符分割,不如说‘#’,该怎么办啊? 有没有相关的设置,可以直接改成按“#”吸取? getline的方式不想用,有点麻烦。。 请指教,谢谢:)

by pbridge - C/C++ - 2007-04-19 14:02:14 阅读(988) 回复(2)

#include #include #include <fstream> using namespace std; int main () { fstream file; file.open("mem.bin", ios::out|ios::in|ios::binary); char *mem = new char[10]; memset(mem, 'x', 10); if(file.is_open()) { file.write(mem, 10); file.close(); } else { cout<<"Unable to open file!"<

by JustUSTC - C/C++ - 2006-12-03 20:30:16 阅读(3911) 回复(10)