On Thu, Jun 11, 2009 at 4:32 AM,
piyush_4love_4ever<[email protected]> wrote:

> can we chage a char type string into a int type variable.
>  pls show how is it possible ?
> suppose i define
>  char *str;

You forgot to allocate memory for *str

>  gets(str) ;   // suppose we get two int in str

Never ever use gets(). It's notorious for introducing buffer overflow
into a program since it doesn't check the length of input. Use fgets()
or other functions that check for the length of the input.

>  now i want to store these two int into a single int type variable.
>  how is it possible??

You can't store two integers in a single int (unless you mean you want
to add them together and store the result in the int). You will need
to split the string into two strings and then use atoi() to convert to
integers.

-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
    If I were to divulge it, it would overturn the world."
               -- Jelaleddin Rumi

Reply via email to