scorrpeio
Full Member level 5
Hello,
I have variables in float which I am interested in converting to char array.
For this I used sprintf function and enabled full support to library functions in Code Composer Studio 4.
when I see the output of this piece of code
I see like this ...
I dont understand why is this happening.
If I give a value less than 8 digits (12345678) I get desired output.
I have made stack size 1000bytes and heap size 960 bytes. I think, this is sufficient for sprintf function.
Please let me know, how to resolve this issue.
I have variables in float which I am interested in converting to char array.
For this I used sprintf function and enabled full support to library functions in Code Composer Studio 4.
Code:
//global declaration
// Struct_Parameters_RunMode.f32TotalisedFlow is a float type in a structure
UINT8_T G_u8TotalisedFlow_ASCII[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
UINT8_T G_u8Size_Totalised = 0;
Struct_Parameters_RunMode.f32TotalisedFlow = 1234506789;
sprintf( (UINT8_T*)G_u8TotalisedFlow_ASCII, "%.0f", Struct_Parameters_RunMode.f32TotalisedFlow );
while(G_u8TotalisedFlow_ASCII[G_u8Size_Totalised]!= DEF_NULL )
{
G_u8Size_Totalised++;
}
when I see the output of this piece of code
I see like this ...
Code:
G_u8TotalisedFlow_ASCII[13] = {'1','2','3','4','5','0','6','7','9','2'};
I dont understand why is this happening.
If I give a value less than 8 digits (12345678) I get desired output.
I have made stack size 1000bytes and heap size 960 bytes. I think, this is sufficient for sprintf function.
Please let me know, how to resolve this issue.