Brett McCoy wrote: > On Thu, Jun 11, 2009 at 9:38 AM, Thomas Hruska<[email protected]> wrote: >> piyush_4love_4ever wrote: >>> can we chage a char type string into a int type variable. >>> pls show how is it possible ? >>> suppose i define >>> char *str; >>> gets(str) ; // suppose we get two int in str >>> now i want to store these two int into a single int type variable. >>> how is it possible?? >> You are going to get a lot of flak for using gets(). >> >> To answer your question: atoi() (if your compiler supports it) is the >> easiest method or strtol() (much more portable). > > atoi() is part of the same standards as strtol(), isn't it? > >>From the atoi man page: > CONFORMING TO > SVr4, POSIX.1-2001, 4.3BSD, C99. C89 and POSIX.1-1996 include > the functions atoi() and atol() only. > > and the strtol manpage: > > CONFORMING TO > strtol() conforms to SVr4, 4.3BSD, C89, C99 and POSIX.1-2001, > and strtoll() to C99 and POSIX.1-2001. > > -- Brett > ------------------------------------------------------------ > "In the rhythm of music a secret is hidden; > If I were to divulge it, it would overturn the world." > -- Jelaleddin Rumi
I must be thinking itoa(). I don't use any of the above since I wrote my own homegrown solutions to attempt to get away from Fusion-based runtimes. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
