Bored and experiencing "programmer's block" with a less trivial project, I've made this little app that prints out the actual 1s and 0s that make up a file you pass as the first command line argument to it
Code:
#include <stdio.h>
int main(int argc, char *argv[])
{
char buf[1000000];
int i;
FILE *fp;
short curBit;
int size;
if(argc!=2)
{
printf("Invalid usage");
return 0;
}
fp = fopen(argv[1], "rb");
if(!fp)
{
printf("Could not open %s", argv[1]);
return 0;
}
fread(buf, sizeof(buf), 1, fp);
size = filelength(fileno(fp));
for(i = 0; i < 1000000; i++)
{
char temp = buf[i];
int i2;
for(i2 = 0; i2 < 8; i2++)
{
curBit = ((temp >> 7) & 0x1);
printf("%d", curBit);
temp = temp << 1;
}
if((size < 1000000) && (i == size))
{
break;
}
}
return 0;
}