Sythe.Org Forums     Register     FAQ     Members List     Calendar     Mark Forums Read    
 
Sythe.Org Forums  
   Runescape Gold

Sythe.org — A Virtual Goods Trading Hub

Make real cash! buying and selling in-game items.

We have a no-scam policy.

You can make thousands playing your favourite games here at Sythe.org.

Just sign up an account and follow the rules!


Take me to

Runescape Markets

Other Game Markets

Support Center

Register an Account

Close
View the 1's and 0's that make up a file!
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 12-22-2010, 02:23 AM
Govind's Avatar
Hero
Highly Respected Highly Trusted Sythe Verified User
 
Join Date: Apr 2005
Posts: 7,068
Default View the 1's and 0's that make up a file!

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;
}

Last edited by SMR : 12-23-2010 at 04:33 AM.
Reply With Quote
Reply



Cheap RS Gold Store  Runescape Gold

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT +1. The time now is 07:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.1