Friday, August 7, 2009

C functions - Windows Vs Linux

On a Windows machine,
we use,
"itoa(str,num,radix)", for converting an integer "num" to a string "str".
"atoi(str)", for converting a string "str" to integer.

But on a linux machine, these functions donot work when we use "gcc" for compilation. The equivalent functions are,
itoa --> sprintf(str,"%d",num);
Here, the second argument should be the format specifier of the number to be converted.

atoi --> sscanf(str,"%d",$num);
Here the second argument is the format specifier of the number to be converted into and
the third argument should be the address of the number variable.

1 comment:

  1. I guess this is a forum of a techie rather than a blog........

    ReplyDelete