I need to convert a char to an int...
Any advice would be greatly appreciated.
I am doing something to this effect:
cin.getline(input, 30, '\n');
I then break up the input to consecutive words
ex: wait 5
word1 will store wait
word2 will store 5
but, I need some way to convert 5 in word2 to an int to pass to another function that increments a clock.
Just a simple conversion will do... Thank you anyone and everyone
atoi vs. strtol, here is the diff.
[quote]
Hi,
what's
code:--------------------------------------------------------------------------------
strtol();
--------------------------------------------------------------------------------
and in what headerfile is it?
I've never heared about it.
[/qoute]
atoi
Convert strings to integer atoi.
int atoi( const char *string );
Routine Required Header Compatibility
atoi <stdlib.h> ANSI, Win 95, Win NT
vs.
strtol
Convert strings to a long-integer value.
long strtol( const char *nptr, char **endptr, int base );
Routine Required Header Compatibility
strtol <stdlib.h> ANSI, Win 95, Win NT
I hope this helps!