gpt4 book ai didi

c++将_bstr_t转换为int并将int转换为_bstr_t

转载 作者:行者123 更新时间:2023-11-28 03:22:04 28 4
gpt4 key购买 nike

我遇到了一个问题,这是我的代码,

          _bstr_t bstrTrans=L"2";
wsprintf(buf,L"insert into inven(ID) values(%s)",(wchar_t *)bstrTrans)//insert into database
//this can work fine, now we want to let bstrTrans add 1, likes this
int bstrTrans2 = atoi(bstrTrans) + 1;
wsprintf(buf,L"insert into inven(ID) values(%s)",(wchar_t *)bstrTrans2 )
// now ,it cannot work.

所以任何人都可以帮助我?

最佳答案

为什么不是简单的 s -> d 呢?

    _bstr_t bstrTrans=L"2";
wsprintf(buf,L"insert into inven(ID) values(%s)",(wchar_t *)bstrTrans)

//insert into database
//this can work fine, now we want to let bstrTrans add 1, likes this
int bstrTrans2 = atoi(bstrTrans) + 1;
wsprintf(buf,L"insert into inven(ID) values(%d)",bstrTrans2 )

编辑:嗯,这有用吗?

    _bstr_t bstrTrans=L"2";
wsprintf(buf,L"insert into inven(ID) values(%s)",(wchar_t *)bstrTrans)

//insert into database
//this can work fine, now we want to let bstrTrans add 1, likes this
char t[30];
bstrTrans = itoa ( atoi (bstrTrans) + 1 , t,10);
wsprintf(buf,L"insert into inven(ID) values(%s)",(wchar_t *)bstrTrans)

关于c++将_bstr_t转换为int并将int转换为_bstr_t,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15153846/

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