• Log in or sign up for an account here: https://www.sythe.org/login

View the 1's and 0's that make up a file!

Govind

The One Musketeer

Highly Respected
Mudkips
Retired Administrator
Joined
Apr 22, 2005
Sythe Gold
23
Messages
7,825
Le Monkey
PHP Shit Show 2k26
Potamus
Prove it!
Sythe Awards 2011 Winner
Tier 1 Prizebox
Tortoise Penis
Trole
UWotM8?
Wait, do you not have an Archer rank?
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;
}
 
duelarena.gg
Back
Top