hi im new in programming in C, can someone help me with a exam problem

jdubiejdubie argentina

Make a program that scans a int and transforms it into a string , without using sprintf ,itoa or using the ascii code

thanks for the help....

sory for the bad english.......

Comments

  • Make a function that returns a char * and takes an integer as a parameter, or perhaps a void function that has an array of chars along with the int, and the size of the of array of chars as parameters.

    In the function use a loop while the int is greater than zero to extract and assign each digit of the integer using % 10 + '0' to the array of chars; divide the int by 10; increment the index pos of the array of chars.

    After the loop exits, the array of chars will be backward, so reverse it. Lastly, terminate the array of chars using 0 or '\0'.

    Post your code if you need more help. :)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion