Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting string to int 1

Status
Not open for further replies.

Ezequiel

Programmer
Apr 4, 2001
30
CA
I'm trying to do the following:

int intDelay;
string timeIntDelay;

(...)

if( timeIntDelay != "" )
intDelay = atoi ( timeIntDelay );

While trying to compile I get the following error:

rtatomic.cpp: In method `RTAtomic::RTAtomic(const class string & = "RTAtomic")':
rtatomic.cpp:51: cannot convert `timeIntDelay' from type `string' to type `const char *'

How can I get the int value from a string?!?! Isn't "atoi" the correct function?

Thanks in advance!
Eze. ---
Ezequiel Glinsky
eze@bumeran.com
Buenos Aires, Argentina
 
atoi ( timeIntDelay.c_str() ); John Fill
1c.bmp


ivfmd@mail.md
 
Great! Thanks John! ---
Ezequiel Glinsky
eze@bumeran.com
Buenos Aires, Argentina
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top