i'm trying to convert a string into an integer by using atoi() function. but it gives me an error:
error C2664: 'atoi' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

i've looked up how to use atoi() and i'm positive i'm using it right can someone offer some insight?

string b;
//b is given a value inbetween these two commands by way of
//a loop.
tree.Insert(atoi(b));

thanks for any help

Recommended Answers

All 2 Replies

atoi needs a pointer to a C-style string.

tree.Insert(atoi(b.c_str()));

thanks that worked great.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.