Question about Boost string tokenizer

Hi, I have the following loop to tokenize a string. But how can I pass the sub-string to ato()? for(boost::tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg){ int value = atoi(*beg); cout << value << "\n"; i++; } I get this error, in my code: : error: cannot convert 'const std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to 'const char*' for argument '1' to 'int atoi(const char*)'

I find a solution to my problem. sorry for the confusion. On 5/25/07, Meryl Silverburgh <silverburgh.meryl@gmail.com> wrote:
Hi,
I have the following loop to tokenize a string. But how can I pass the sub-string to ato()?
for(boost::tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg){ int value = atoi(*beg);
cout << value << "\n"; i++; }
I get this error, in my code: : error: cannot convert 'const std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to 'const char*' for argument '1' to 'int atoi(const char*)'

"Meryl Silverburgh" <silverburgh.meryl@gmail.com> wrote in message news:701fce30705250938k2a64bac8i856e9433f009d65d@mail.gmail.com...
Hi,
I have the following loop to tokenize a string. But how can I pass the sub-string to ato()?
for(boost::tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg){ int value = atoi(*beg);
cout << value << "\n"; i++; }
I get this error, in my code: : error: cannot convert 'const std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to 'const char*' for argument '1' to 'int atoi(const char*)'
Try: int value = atoi(beg->c_str()); - Dennis
participants (2)
-
Dennis Jones
-
Meryl Silverburgh