#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
FILE *filename;
void main(int argc, char *argv[])
{
int rec;
int x,z;
char temp1[25];
char temp2[25];
rec=0;
if(argc>2)
{
printf("Usage: BINARY [outfile]\n"
;
printf("Usage: BINARY <ENTER>\n"
;
exit(0);
}
if(argv[1])
{
fclose(filename);
filename=fopen(argv[1],"w"
;
if(filename!=NULL) rec=1;
if(rec==1) fprintf(filename,"\nBeavis rules!\n"
;
}
clrscr();
for(z = 1; z < 101; z++)
{
if(z<10)
{ printf( "\n DEC: 00%d |", z);
if(rec==1) fprintf(filename,"\n DEC: 00%d |", z);
goto BHEAD;
}
else if (z<=99 && z>9)
{ printf( "\n DEC: 0%d |", z);
if(rec==1) fprintf(filename,"\n DEC: 0%d |", z);
goto BHEAD;
}
else
{ printf ( "\n DEC: %d |", z);
if(rec==1) fprintf(filename,"\n DEC: %d |", z);
goto BHEAD;
BHEAD:
printf(" HEX: %02X |", z); if(rec==1) fprintf(filename," HEX: %02X |", z);
printf( " BIN: " ); if(rec==1) fprintf(filename," BIN: "
;}
strcpy (temp1,""
;
strcpy (temp2,""
;
for(x=15; x> 7; x--)
for( x=7; x> -1; x--)
{
printf( "%i", (z & 1 << x) > 0 ? 1 :0);
sprintf(temp1,"%i", (z & 1 << x) > 0 ? 1 :0);
strcat(temp2,temp1);
}
strcat(temp2,"\n"
; //remove spaces btwn lines in outfile
printf( "\n" ); //removes spaces onscreen
if(rec==1) fprintf(filename,temp2);
}
if(rec==1) fprintf(filename,"\r\nThank you for flying Butthead Airlines!\n"
;
if(rec==1) fclose(filename);
}
#include <stdlib.h>
#include <conio.h>
#include <string.h>
FILE *filename;
void main(int argc, char *argv[])
{
int rec;
int x,z;
char temp1[25];
char temp2[25];
rec=0;
if(argc>2)
{
printf("Usage: BINARY [outfile]\n"
printf("Usage: BINARY <ENTER>\n"
exit(0);
}
if(argv[1])
{
fclose(filename);
filename=fopen(argv[1],"w"
if(filename!=NULL) rec=1;
if(rec==1) fprintf(filename,"\nBeavis rules!\n"
}
clrscr();
for(z = 1; z < 101; z++)
{
if(z<10)
{ printf( "\n DEC: 00%d |", z);
if(rec==1) fprintf(filename,"\n DEC: 00%d |", z);
goto BHEAD;
}
else if (z<=99 && z>9)
{ printf( "\n DEC: 0%d |", z);
if(rec==1) fprintf(filename,"\n DEC: 0%d |", z);
goto BHEAD;
}
else
{ printf ( "\n DEC: %d |", z);
if(rec==1) fprintf(filename,"\n DEC: %d |", z);
goto BHEAD;
BHEAD:
printf(" HEX: %02X |", z); if(rec==1) fprintf(filename," HEX: %02X |", z);
printf( " BIN: " ); if(rec==1) fprintf(filename," BIN: "
strcpy (temp1,""
strcpy (temp2,""
for(x=15; x> 7; x--)
for( x=7; x> -1; x--)
{
printf( "%i", (z & 1 << x) > 0 ? 1 :0);
sprintf(temp1,"%i", (z & 1 << x) > 0 ? 1 :0);
strcat(temp2,temp1);
}
strcat(temp2,"\n"
printf( "\n" ); //removes spaces onscreen
if(rec==1) fprintf(filename,temp2);
}
if(rec==1) fprintf(filename,"\r\nThank you for flying Butthead Airlines!\n"
if(rec==1) fclose(filename);
}