944,082 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2961
  • C RSS
Nov 14th, 2005
0

Please help with atoi()

Expand Post »
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?

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

thanks for any help
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
LordJayno is offline Offline
6 posts
since Oct 2005
Nov 14th, 2005
0

Re: Please help with atoi()

atoi needs a pointer to a C-style string.
  1. tree.Insert(atoi(b.c_str()));
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Nov 14th, 2005
0

Re: Please help with atoi()

thanks that worked great.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
LordJayno is offline Offline
6 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Storing data into an Array
Next Thread in C Forum Timeline: Client vs Window





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC