Right left middle string functions in C?

I'm coding something in C and I have a number of variable size up to 3 digits, that I would like to convert to a float. For example, I have 250, I'd like it to show up as 2.50 or if I have 5 I'd like it to show as .05.
What possible ways can I do that? I had thought of sprintf() to make it a string and format it, but I can't figure out how to pull the the numbers to format it with a . in the right spot. atof() ended up with things like 250.00.  Thanks in advance!
Who is Participating?
Hmmm.... assuming you want the decimal always to be in the same spot...

float fBase = atof(szVarSize3);
fBase = fbase/100; // OK, got the "correct number"
char szOut[5];
sprintf(szOut, "%.2f", fBase); // String version of it

GizaAuthor Commented:
Thanks, that did the trick perfectly!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.