rt,一般的c++二进制输入输出流都是将取出的字节赋值给char*, 但是又不知道怎样将char*转化为string类型,请指教,谢谢。:shock:
by beautifulsea - C/C++ - 2007-04-30 12:25:26 阅读(3536) 回复(3)
string s; s.reserve(100); string s_another("another"); s = s_another; <<----------- 这句是否会把s自己的缓冲区释放掉,而s与s_another共用同一个缓冲区? 在VC下是的,如何让s用自己的缓冲区,而不与s_another用一样的?
有一个string[] 数组为string[] a = new string[]{"11","11","22","33"}; 我想要把相同的项去掉,返回个每项都不同的数组,结果为 string[]{"11",“22","33"}; 请大侠指点!!
#include
byte buff[] = new byte[64]; string ss; 如何将buff的内容转入ss 中呢? 另外,如何将buff的内容清空为0 多谢!!!!
比如: #include<string>; string s; 我想读入一行字符到其中(包括空格)!!就像对于char*型的 cin.getline()函数一样。 应该怎么样处理呢? 我认为它应该有个成员函数才能实现这个功能…… 老师叫我自己查…… 请各位知道的大哥赐教!!
/* f.cpp : 代码转换示例C++程序 */
#include
如何将 $string = "{file => 'file1', desc => 'test}, {file => 'file12', desc => 'test2'}" 转换成 my @array_of_hashes = ( {file => 'file1', desc => 'test}, {file => 'file12', desc => 'test2'}, ); sting 转 array比较容易 采用split 的方法。可以找倒很多示范 但是如何将string转换成array of hashes ?????? 谢谢
JAVA里面关于byte数组和string之间的转换问题 引自:http://soniccyj.bokee.com/6175850.html JAVA里面关于byte数组和string之间的转换问题 把byte转化成string,必须经过编码。 例如下面一个例子: import java.io.UnsupportedEncodingException; public class test{ public static void main(string g[]) { string s = "12345abcd"; byte b[] = s.getBytes(); string t = b.tostring(); System.out.println(t); } } 输出...