gpt4 book ai didi

c++ - 从 VS6 到 VS2010 的 ostringstream 转换

转载 作者:太空宇宙 更新时间:2023-11-04 14:16:37 25 4
gpt4 key购买 nike

我的这段代码在 VS6 下运行良好,但在 VS2010 中出现错误:

void CGreatString::operator>> (char * lpszDest)
{
strcpy (lpszDest, str());
rdbuf()->freeze(0);
}

我找到了 this 对于类似于我的问题的东西,但它仍然没有用......

据我所知,ostrstream 在 VS2010 中已被弃用,所以我尝试了这个:

void CGreatString::operator>> (char * lpszDest)
{
ostringstream os;
string str = os().str(); //Error 1 and 2
strcpy (lpszDest, str.c_str());
os.rdbuf()->freeze(0); //Error 3
}

但我仍然遇到错误:

1- error C2064: term 不计算为带 0 个参数的函数

2- 错误 C2228:'.str' 的左边必须有类/结构/union

3- 错误 C2039:“卡住”:不是“std::basic_stringbuf<_Elem,_Traits,_Alloc>”的成员

谢谢!

最佳答案

所以迷你 Markdown 在评论中不起作用。太好了,这只是炉排。

void CGreatString::operator>> (char * lpszDest)
{
// copy lpszDest into my CGreatString
// The code you write does nothing at all.
}

关于c++ - 从 VS6 到 VS2010 的 ostringstream 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10620615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com