View Full Version: special charachters/ making custom functions

C++ Learning Community > C++ Tips > special charachters/ making custom functions


Title: special charachters/ making custom functions
Description: an accident at first


ih8censorship - June 27, 2003 02:13 AM (GMT)
well this started out as an accident when returning a value other than zero in a char varaible. i found out that by doing this you can control different things and make little smiley faces and things like that that must be built into computers and/or c++. since i was reading about making custom functions today i figured id try that too so heres a combination of special charachters i accidently figured out how to do and making custom functions.

CODE

#include <iostream>
using namespace std;

char smiley() /* these make  custom functions for our next process */
{
return 1;
}

char smiley2()
{
return 2;
}

char heart()
{
return 3;
}

char diamond()
{
return 4;
}

char clubs()
{
return 5;
}

char spade()
{
return 6;
}

char somethin()
{
return 20;
}

char somethin2()
{
return 19;
}

char arrows()
{
return 18;
}


char triangle()
{
return 17;
}

char right()
{
return 16;
}

char sun()
{
return 15;
}

char musical()
{
return 14;
}



char female()
{
return 12;
}


char male()
{
return 11;
}

char some()
{
return 9;
}

char sos()
{
return 21;
}

char block()
{
return 22;
}

char arrowz()
{
return 23;
}

char up()
{
return 24;
}

char down()
{
return 25;
}



char pictures() /* a custom function which uses custom functions from previous coding */
{
cout<<smiley()<<"  smiley face 1   "<<smiley2()<<"  smiley face 2"<<"\n"; /*remember writing these function names? heres a bit on how to use them*/
cout<<heart()<<"  a heart         "<<diamond()<<"  a diamond"<<"\n";
cout<<clubs()<<"  suit of clubs   "<<spade()<<"  suit of spades"<<"\n";
cout<<somethin()<<"  i dunno         "<<somethin2()<<" two exclamation points"<<"\n";
cout<<arrows()<<"  arrow thingie   "<<triangle()<<" left pointing triangle"<<"\n";
cout<<sun()<<"  sun?            "<<right()<<" right pointing triangle"<<"\n";
cout<<musical()<<"  musical note    "<<female()<<" female symbol"<<"\n";
cout<<male()<<"   male symbol    "<<sos()<<" i dunno"<<"\n";
cout<<up()<<"   up arrow       "<<down()<<" down arrow"<<"\n";

cout<<"\n"<<"\n";
return 0;
}

int main() /*program STARTS executing here */
{
cout<<"some things you can \"draw\" with c++:"<<"\n"<<"\n";
cout<<pictures()<<"\n"<<"\n";           /* outputs the custom function "pictures" to the screen, and makes a blank line afer it*/
cout<<"there are probley more i dident figure out."<<"\n";
system("PAUSE");
}


/* well thats the basics of making your own custom functions, i know theres more to
makeing more advanced functions, but i accidently found out those c++ "pictures
so i figured i would show you how to make them, and while im at it teach you something
more usefull too :) */




i think some of the special charachters could be usefull in a simple game, and the custom functions have the possibility of making a large program more compact in a sense.

Shadow of the Moon - June 27, 2003 02:20 AM (GMT)
It doesn't work for me and I can't figure out why. :(
The linker pukes and says you have a circuler link going on.

ih8censorship - June 27, 2003 02:26 AM (GMT)
thats really weird... worked perfect for me. what are you compileing it as? you use dev c++ right?

dr voodoo - June 27, 2003 03:27 PM (GMT)
Antitrust try if this works:
CODE
#include <iostream>
using namespace std;
int main()
{
   for(int i=0;i<256;i++)
   {
       cout<<(char)i<<endl;
   };
   system("PAUSE");
}

It will give you all charachters in a consol window.

ih8censorship - June 27, 2003 03:42 PM (GMT)
nice example of for dr voodoo. can anyone else compile the code i posted besides me? if no one could that would be very strange...

Dragon - June 27, 2003 05:08 PM (GMT)
It works fine for me.

Shadow of the Moon - June 27, 2003 05:44 PM (GMT)
I compiled it as a console app. I don't know what the problem could be. Dr. Voodoo's one worked though.

It works because a char is just an ascii value.

Dragon - June 27, 2003 05:51 PM (GMT)
I also compiled it as an console application.




* Hosted for free by InvisionFree