For my program , I want to convert an integer into array of characters. I
see C has an atoi function o convert from an array of characters to
integers but no standard function to convert from integer to an array opf
chars. Why so ? Does that conversion not come into practice ?
we have sprintf but that riddles with the buffer-overflow problem :( and
snprintf is not in ANSI but in C99.
I have a network program in C ( which is not topical here, hence I did
not post the code). The client sends a number to the server and server
squares the number and sends it back to the client. Now any communication
between them happens using characters. So client sends an array of
characters to the server:
arr[] = { '3', '\0' };
and the server reads and square the number and sends this array back to
the client:
arr_new[] = { '9', '\0' };
Right now I solved the problem using sprintf and by using the number whose
squares are of one digit and I have also limited the size of array to 2
only.
but is this the C way of doing things ?
--
http://lispmachine.wordpress.com/
my email ID is @ the above blog.
just check the "About Myself" page :)