home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
challenge
/
13.12
/
Challenge.sit.hqx
/
Challenge
/
bitnumLister.c
next >
Wrap
C/C++ Source or Header
|
1997-10-23
|
1KB
|
53 lines
void main(void)
{
StandardFileReply reply;
short refnum;
long i;
OSType mySeparator = ',\r ';
OSType mySpace = ' ';
long lineCt = 0;
InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();
StandardPutFile("\p", "\pbitnum", &reply);
if (!reply.sfGood || reply.sfReplacing)
ExitToShell();
if (FSpCreate(&reply.sfFile, 'ttxt', 'TEXT', reply.sfScript))
ExitToShell();
FSpOpenDF(&reply.sfFile, fsRdWrPerm, &refnum);
for ( i= 0; i <= (256 * 256 - 1); i++)
{
long bitShift, shifted;
long bitsCt = 0;
long stringSize;
Str255 myString;
for (bitShift = 0; bitShift < 16; bitShift++)
if ((i >> bitShift) & 0x01)
bitsCt++;
NumToString(bitsCt, myString);
stringSize = myString[0];
if (stringSize == 1)
FSWrite(refnum, &stringSize, &mySpace);
FSWrite(refnum, &stringSize, &myString[1]);
if (++lineCt == 16)
{
stringSize = 2;
lineCt = 0;
} else
stringSize = 1;
FSWrite(refnum, &stringSize, &mySeparator);
}
FSClose(refnum);
}