Originally Posted by
opaw
could be better but i have no idea to lop it off.
in VB we can used MID() function
but how about in C ?
Code:
char test[] = "123456.123456";
test[11] = '\0';
perhaps?
Of course that's just an example, strchr() may help you.
or a bit of casting:
Code:
#include <stdio.h>
int main(void)
{
double test = 123456.123456;
int places = 10 * 10 * 10 * 10, /* 4 decimal places, 10^4 */
cast = 0,
test2 = 0;
/* truncate decimals */
cast = (int) test;
test2 = (test - cast) * places;
printf("%d.%d\n", cast, test2);
return 0;
}
Again, it's a demo don't use it