std :: string出现无法解释的错误 [英] Inexplicable error with std::string

查看:85
本文介绍了std :: string出现无法解释的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我为什么下面的代码会产生下面的错误吗?我在这里疯了!
疯了!我错过了一些非常明显和简单的东西吗?


std :: string :: size_type idx;

std :: string one_line;

..

..

..

idx = one_line.find(''\t'',0);

错误C2059:语法错误:''常数''

Can anybody tell me why the code below should produce the error below? I''m
going nuts here! Am I missing something incredibly obvious and simple?

std::string::size_type idx;
std::string one_line;
..
..
..
idx = one_line.find(''\t'', 0);
error C2059: syntax error : ''constant''

推荐答案

" Dave"其中p是*********** @ yahoo.com>在消息中写道

news:vv ************ @ news.supernews.com
"Dave" <be***********@yahoo.com> wrote in message
news:vv************@news.supernews.com
任何人都可以告诉我为什么下面的代码应该产生错误
下面?我疯了!我错过了一些非常明显的东西吗?

std :: string :: size_type idx;
std :: string one_line;



idx = one_line.find(''\t'',0);

错误C2059:语法错误:''常数''
Can anybody tell me why the code below should produce the error
below? I''m going nuts here! Am I missing something incredibly obvious
and simple?

std::string::size_type idx;
std::string one_line;
.
.
.
idx = one_line.find(''\t'', 0);
error C2059: syntax error : ''constant''



尝试提供产生错误的完整可编译样本。您提供的

三行与VC ++ 2002和Comeau

在线编译良好。

-

John Carson

1.要回复电子邮件地址,请删除donald

2.不要回复电子邮件地址(在此处发帖)

>


Try supplying a complete compileable sample that produces the error. The
three lines you have supplied compile fine with both VC++ 2002 and Comeau
online.
--
John Carson
1. To reply to email address, remove donald
2. Don''t reply to email address (post here instead)




" John Carson" <做*********** @ datafast.net.au>在消息中写道

news:3f ****** @ usenet.per.paradox.net.au ...

"John Carson" <do***********@datafast.net.au> wrote in message
news:3f******@usenet.per.paradox.net.au...
" Dave"其中p是*********** @ yahoo.com>在消息中写道
新闻:vv ************ @ news.supernews.com
"Dave" <be***********@yahoo.com> wrote in message
news:vv************@news.supernews.com
任何人都可以告诉我为什么下面的代码应该产生错误
下面?我疯了!我错过了一些非常明显的东西吗?

std :: string :: size_type idx;
std :: string one_line;



idx = one_line.find(''\t'',0);

错误C2059:语法错误:''常数''
Can anybody tell me why the code below should produce the error
below? I''m going nuts here! Am I missing something incredibly obvious
and simple?

std::string::size_type idx;
std::string one_line;
.
.
.
idx = one_line.find(''\t'', 0);
error C2059: syntax error : ''constant''



尝试提供产生错误的完整可编译样本。你提供的三行你可以在线编译VC ++ 2002和Comeau


-
John Carson
1.回复电子邮件地址,删除唐纳德
2.不要回复电子邮件地址(在这里发帖)


Try supplying a complete compileable sample that produces the error. The
three lines you have supplied compile fine with both VC++ 2002 and Comeau
online.
--
John Carson
1. To reply to email address, remove donald
2. Don''t reply to email address (post here instead)




我不知道这是否有帮助,但这里是完整的功能。但是,要为
提供足够的上下文以使其完全可编译,将会产生数千行代码。所以,这是我能做的最好的,但是我知道如果它没有足够的上下文并且没有帮助......(BTW我的平台是VC ++ 7.1,但我是/>
假设这不重要;着名的遗言......)


无效卖出:: ChangeSale()

{

std :: string :: size_type first_char;

std :: string :: size_type idx;

std :: string :: size_type last_char;

int num_tabs;

std :: string one_line;

std :: string percent;

int total( 0);


for(int i = 0; i< mVisibleMatchUps_psxListBox-> count(); ++ i)

{

one_line = std :: string(mVisibleMatchUps_psxListBox-> text(i));

num_tabs = std :: count(one_line.begin(),one_line.end(),'' \t'');


if(num_tabs< 7)

继续;


idx = one_line.find(''\t'',0);

first_char = idx + 1 ;

last_char = one_line.find(''\t'',first_char) - 1;


if(last_char< first_char)

继续;


%= one_line.substr(first_char,last_char - first_char + 1);

总计+ = atoi(percent.c_str());


}


mVisibleMatchUps_psxListBox-> storeData();

DeleteSale();

AddSale();

} // ChangeSale(...



I don''t know if this will help, but here''s the full function. However, to
provide enough context to make it fully compileable would draw in thousands
of lines of code. So, this is the best I can do, but I understand if it''s
not enough context and doesn''t help... (BTW my platform is VC++ 7.1, but I
suppose that shouldn''t matter; famous last words...)

void Sell::ChangeSale()
{
std::string::size_type first_char;
std::string::size_type idx;
std::string::size_type last_char;
int num_tabs;
std::string one_line;
std::string percent;
int total(0);

for (int i = 0; i < mVisibleMatchUps_psxListBox->count(); ++i)
{
one_line = std::string(mVisibleMatchUps_psxListBox->text(i));
num_tabs = std::count(one_line.begin(), one_line.end(), ''\t'');

if (num_tabs < 7)
continue;

idx = one_line.find(''\t'', 0);
first_char = idx + 1;
last_char = one_line.find(''\t'', first_char) - 1;

if (last_char < first_char)
continue;

percent = one_line.substr(first_char, last_char - first_char + 1);
total += atoi(percent.c_str());

}

mVisibleMatchUps_psxListBox->storeData() ;
DeleteSale() ;
AddSale() ;
}//ChangeSale(...




" Dave"< be *********** @ yahoo.com>在消息新闻中写道:vv ************ @ news.supernews .com ...

]>。

"Dave" <be***********@yahoo.com> wrote in message news:vv************@news.supernews.com...
]> .
idx = one_line.find(''\t'',0);
idx = one_line.find(''\t'', 0);



尝试在此行之前坚持#undef查找。该行看起来很好,可能是一些小丑

重新定义查找。


Try sticking an #undef find before this line. The line looks fine, could be some joker
redefined find.


这篇关于std :: string出现无法解释的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆