| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Just made this little kluge for a project at work, thought I'd share.
c Code:
1 reputation point to the first one to tell me what it does. (2 if you do it without compiling and running it).
__________________
This is my code. Is it not nifty? "The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools." ---Douglas Adams Join the Itsacon fanclub! Zero Tolerance: Spammers banned so far: 280
![]() |
|
#2
|
||||
|
||||
|
Hmmm. Im still thinking.
lol. I see the inline if else and stuff but, , Well, I guess Im going to go compile this now and see what I can come up with How bout a little clue. ![]() |
|
#3
|
||||
|
||||
|
Try making the string h something like "Babe", or "1334", or "C0ffee"
|
|
#5
|
||||
|
||||
|
Quote:
|
|
#6
|
||||
|
||||
|
Yep. I had to compile it and run it to figure it out, though, since it was a tard hard to process mentally.
How long did it take you to write that? |
|
#7
|
||||
|
||||
|
Honestly? less than 10 minutes...and that's including the rest of the function, which I'll post once Geo has figured it out
.What can I say...I like to think in binary one of the perks of working with MC's I guess... |
|
#8
|
||||
|
||||
|
Well, you better post it then because if you wait for me we might be here a while, lol. I tried compiling it and it crashed during run time. Maybe thats because I put it in the main block and then compiled it, that is writing a C++ console app.
. So, lets have it. I am interested at what it does. Im just not far enough along to make out what its for. |
|
#9
|
||||
|
||||
|
It crashed? typical...
It needs the ctype.h library, and you need to assign a string to the *h pointer..., like: Code:
unsigned char *h = "Babe"; And then you need to read the value of d at the end of course... |
|
#10
|
||||
|
||||
|
Hey! You went pro! Sig and avatar privs!
Congratulations! |
|
#11
|
||||
|
||||
Ya, I'm so excited, I could pop. lol
__________________
---Official Member Of The Itsacon Fan Club--- ![]() Give a man a fish and he will eat for a day. Teach a man to fish and he will sit in a boat all day drinking beer. |
|
#12
|
||||
|
||||
|
Cool sig!!!
![]() |
|
#13
|
||||
|
||||
|
It's wierd man I keep getting the error cannot assign a const to an unsigned, when I try to assign babe to it. =(
Ya thought you would like that one =) Here's What I got Code:
#include <cstdlib>
#include <iostream>
#include <ctype.h>
using namespace std;
int main(void)
{
unsigned char *h = "babe";
unsigned int d;
for(d = 0 ; isxdigit((int) *h); h++)
d = (d << 4) + (0x0F & *h) + ((0x40 & *h) ? 9 : 0);
system("PAUSE");
return EXIT_SUCCESS;
}
Last edited by Geo.Garnett : October 12th, 2005 at 11:02 PM. |
|
#14
|
|||
|