Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/29/06 17:07
Read: times


 
#121314 - Answers
Responding to: ???'s previous message
Eugene Yong said:
Question 1 :
============

I have tried using sprintf command but it seems that all it does is inserting 12.34 into the Element 0(array[0]) of the array and i dont want that to happen.

Then you must be using sprintf() incorrectly. An example:
char array[sizeof("12.34")];

sprintf(array, "%.2f", floatnum);

Leaves array[] populated thusly:

array[0] = '1'
array[1] = '2'
array[2] = '.'
array[3] = '3'
array[4] = '4'
array[5] = 0

Question 2:
===========

Assuming that the array have to be cleared and rewritten with new floating point number every predetermined loop, is it necessary for me to free the array before inputting new value?

No.

List of 6 messages in thread
TopicAuthorDate
Interger to Array and Buffer question            01/01/70 00:00      
   Answers            01/01/70 00:00      
      While theoritically it should works...            01/01/70 00:00      
         float conversion specifier on a long            01/01/70 00:00      
            Alright            01/01/70 00:00      
   what is that, never heard of it            01/01/70 00:00      

Back to Subject List