Something like this might work for you (might want to clean it up);
#include <stdio.h>
#include <string.h>
int main()
{
char result[128];
char buffer[128];
float f = 345.876f;
sprintf(buffer,"%f",f);
int count = 0;
int r = 0;
int found_point = 0;
for(int i = 0; i < 128 && buffer[i] != 0; ++i) {
if (found_point) {
result[r] = buffer[i];
result[++r] = ' ';
result[++r] = 0;
++count;
}
else {
found_point = buffer[i] == '.' ? 1 : 0;
}
}
if (count > 0) {
strcpy(result + r, "and ");
char c_buffer[128];
sprintf(c_buffer, "%d", count);
strcpy(result + strlen(result), c_buffer);
}
printf("o/p: %s\r\n", result);
return 0;
}
Hope this helps,
Fredrik