From 553e5014604b523303a06ef181f9b451df281aa0 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Fri, 19 Dec 2008 07:26:41 +0000 Subject: [PATCH] Fixed decimal printing git-svn-id: http://picoc.googlecode.com/svn/trunk@12 21eae674-98b7-11dd-bd71-f92a316d2d60 --- str.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/str.c b/str.c index 9005341..dd990fb 100644 --- a/str.c +++ b/str.c @@ -35,7 +35,8 @@ int StrEqualC(const Str *Str1, const char *Str2) void StrPrintInt(int Num, FILE *Stream) { int Div; - int Remainder; + int Remainder = 0; + int Printing = FALSE; if (Num < 0) { @@ -51,7 +52,11 @@ void StrPrintInt(int Num, FILE *Stream) while (Div > 0) { Remainder = Num / Div; - fputc('0' + Remainder, Stream); + if (Printing || Remainder > 0) + { + fputc('0' + Remainder, Stream); + Printing = TRUE; + } Num -= Remainder * Div; Div /= 10; }