| | |
Please help with atoi()
![]() |
•
•
Join Date: Oct 2005
Posts: 6
Reputation:
Solved Threads: 0
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?
thanks for any help
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?
C Syntax (Toggle Plain Text)
string b; //b is given a value inbetween these two commands by way of //a loop. tree.Insert(atoi(b));
thanks for any help
atoi needs a pointer to a C-style string. C Syntax (Toggle Plain Text)
tree.Insert(atoi(b.c_str()));
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- help me about atoi (C++)
- The Calculator (C++)
- Cubing Digits Individually (C++)
- MS Visual++ 6.0 - Error C2146, C2501 ... (C++)
- ASCII to BINARY, & VICA VERCA (C++)
- hm.. wiered.. (C)
- struct error (!?) (C)
- ** Need Help ** in a small C++ problem (C++)
Other Threads in the C Forum
- Previous Thread: Storing data into an Array
- Next Thread: Client vs Window
| Thread Tools | Search this Thread |
* ansi api array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile creafecopyofanytypeoffileinc createcopyoffile createprocess() database dynamic execv fflush fgets file floatingpointvalidation fork forloop frequency function getlogicaldrivestrin givemetehcodez grade graphics gtkwinlinux histogram homework i/o ide inches include infiniteloop initialization input interest intmain() iso keyboard km license linked linkedlist linux list looping loopinsideloop. lowest matrix microsoft mysql oddnumber open opendocumentformat openwebfoundation pdf pointer pointers posix power program programming pyramidusingturboccodes radix read recursion recv recvblocked reversing scanf scheduling segmentationfault send sequential shape single socketprogramming stack standard strchr string suggestions test threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi






