View Single Post
Old Nov 13th, 2006, 9:53 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Your terminology is too fuzzy. An array of char, terminated by a '\0', is often referred to as a string, and atoi would accept that. The C++ string class is something else, but you can access its array of char with ElStringo.c_str (). Atoi isn't a great choice, since an error will return the same thing as the value, zero, so you can't tell the difference. There are other things like strtol, etc., that work better. You might also wish to investigate string streams.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote