A c++ Program for Valentines day

S

sandy

Hey guys,

I know this is silly, but I just wanted to take some break from work. I
was just wodering if its possible to write a c++ program that can print
"iloveyou" in shape of 'heart' when executed. The impotant thing is
that, the program should not show any kind of words related to it, i
mean the program should not be understandable at the very first sight
the user goes through the code. It will be gr8 if something more
creative is achieved out of this idea. Think about it. Let me know if
its possible to make a code that can interact with user and print the
results for just one particular kind of input, and print it in a
beautiful way. I am not good enough in c++ to do that, so i was just
wondering someone can help me out with it. Thank you.

sandy
 
M

Mike Wahler

sandy said:
Hey guys,

I know this is silly, but I just wanted to take some break from work. I
was just wodering if its possible to write a c++ program that can print
"iloveyou" in shape of 'heart' when executed.
Certainly.

The impotant thing is

Don't say that on Valentine's Day. :)
that, the program should not show any kind of words related to it, i
mean the program should not be understandable at the very first sight
the user goes through the code. It will be gr8 if something more
creative is achieved out of this idea. Think about it. Let me know if
its possible to make a code that can interact with user and print the
results for just one particular kind of input, and print it in a
beautiful way. I am not good enough in c++ to do that, so i was just
wondering someone can help me out with it. Thank you.

Get some graph paper, and draw the characters (perhaps asterisks) of
the output. After that it should be simple to write some loops to
output various character sequences. If you want to further obfuscate
the source, put random amounts of it in separate functions.

-Mike
 
D

Daniel T.

"Mike Wahler said:
Don't say that on Valentine's Day. :)


Get some graph paper, and draw the characters (perhaps asterisks) of
the output. After that it should be simple to write some loops to
output various character sequences. If you want to further obfuscate
the source, put random amounts of it in separate functions.

You could also build the "i love you" string from ascii values or
individual chars that are distributed in the code.
 
R

red floyd

sandy said:
Hey guys,

I know this is silly, but I just wanted to take some break from work. I
was just wodering if its possible to write a c++ program that can print
"iloveyou" in shape of 'heart' when executed. The impotant thing is
that, the program should not show any kind of words related to it, i
mean the program should not be understandable at the very first sight
the user goes through the code. It will be gr8 if something more
creative is achieved out of this idea. Think about it. Let me know if
its possible to make a code that can interact with user and print the
results for just one particular kind of input, and print it in a
beautiful way. I am not good enough in c++ to do that, so i was just
wondering someone can help me out with it. Thank you.

sandy

Go to www.ioccc.org, they may have something similar. I know they have
stuff that does circles with pi....
 
J

jjcp

hey just a thought you could type cast the int nubers of the charaters
you want to print out. that should be fun :)
 
S

sandy

Thank you guys, i will check out every advise u guys have gave me.
thank you,

Sandy
 
J

Jerry Coffin

sandy said:
Hey guys,

I know this is silly, but I just wanted to take some break from work. I
was just wodering if its possible to write a c++ program that can print
"iloveyou" in shape of 'heart' when executed. The impotant thing is
that, the program should not show any kind of words related to it, i
mean the program should not be understandable at the very first sight
the user goes through the code. It will be gr8 if something more
creative is achieved out of this idea. Think about it. Let me know if
its possible to make a code that can interact with user and print the
results for just one particular kind of input, and print it in a
beautiful way. I am not good enough in c++ to do that, so i was just
wondering someone can help me out with it. Thank you.

One minor point: you've gotten a couple of hints to embed the string as
hex, decimal, etc. numbers in your source code. While this can
obfuscate the source code itself (a little) it has no effect on the
executable -- there the string will stil show up just as if you'd
written it normally.

There are quite a few ways of making it harder to understand. For
example, you could use what is probably the oldest cipher known to man
-- just subtract 3 (or whatever) from each number in the string, and
then add 3 to each character as you print it out.

If you want to make it a bit more complex, you can use a slightly more
complex cipher -- for example, use two strings, and XOR the characters
together as you print them out.

OTOH, instead of obfuscating the string, you could just obfuscate the
code. For example, something like this might be a start in the right
general direction:

#include<iostream>

char *c[] = { "HILO", "NOTYOU", "TRI", "SHOVE" };
char **cp[] = { c+3, c+2, c+1, c };
char ***cpp = cp;

int main() {
std::cout << **++cpp+2;
std::cout << *--*++cpp+2;
std::cout << *cpp[-2]+3;
std::cout << cpp[-1][-1]+3;
return 0;
}

Obfuscation doesn't require #define's!
 
I

int2str

sandy said:
Hey guys,

I know this is silly, but I just wanted to take some break from work. I
was just wodering if its possible to write a c++ program that can print
"iloveyou" in shape of 'heart' when executed. The impotant thing is
that, the program should not show any kind of words related to it,

Here's a start...
I didn't make much effort in hiding the string though. But otherwise it
should be pretty hard to figure out. Compiles without warning on GCC
3.4.4 with -W -Wall -pedantic.

--- snipp ---
#include <iostream>
#include <string>
int main(){std::string g=" I LOVE C++!";
char t[]={0x15,0x0C,0x3F,0x0F,0xE3,0xFC,0xFF,0xBF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0xF8,
0xFF,0xFF,0x83,0xFF,0xF8,0x07,0xFF,0x00,0x1F,0xF0,
0x00,0x3E,0x00,0x00,0x40,0x00};char w=t[0],x=w,h=
t[1],y=h,l=g.length();unsigned i=0;while(y--){x=w;
while(x--){unsigned b=2+i/8,o=7-i%8;std::cout<<(t[
b]&(1<<o)?g[i%l]:' ');i++;}std::cout<<"\n";}}
--- /snipp ---

Cheers,
Andre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top