🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2011

NUMBER SYSTEM CONVERSION PRINTS BACKWARDS - HELP?

#2011
From: Charles Frayer
Date: Fri, 16 Feb 1996 06:11
20 lines
1023 bytes
Greetings - 

I'm converting numbers from an input file from decimal to hex, oct, and bin.
The following code completes the conversion successfully (sort of) and prints
it to a file, but the converted numbers are printed backwards and hex numbers
are all numbers instead of their equivalent letter values.  Any ideas?

	while(lNumToConv > 0)
	{
	  iCoeff = (lNumToConv % iBase); 
	  fprintf(fptrWrite, "%i", iCoeff);
	  lNumToConv = (lNumToConv / iBase);
	}
	fprintf(fptrWrite, "\n");

I know (literally) why they're printing backwards, but not how to correct it.

Thanks,

Charlie ;/)
Technical Details
Message-ID: <4g176b$mrk@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: frayer@expert.cc.purdue.edu (Charles Frayer)
Newsgroups: comp.lang.c.moderated
Subject: NUMBER SYSTEM CONVERSION PRINTS BACKWARDS - HELP?
Date: 16 Feb 1996 00:11:22 -0600
Organization: Purdue University Computing Center
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4g176b$mrk@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com