Beer Fund and itoa
Although I do not feel the need to explain myself to you lesser beings, I shall deign to divulge the reasons behind my putting a "donate" button on my magnificent blog. Yes, I am that great and cool a guy. No, I am not selling out. How can I be selling out when, so far, none of the third-party stuff I put on my blog makes me money? I even removed enetation, haloscan and tagboard because one of them was lame enough to have popups. The only ad on my blog is from webcounter, which feeds my ego, and I'm sure we can all agree that feeding my ego is a Good Thing. Anyway, here are the reasons.
1) It's meant to be funny, you dumb fucks.
2) I do realise that in all probability, no one will actually give me any money, but hey, what the hell. There are all sorts of crazy people on the Internet.
3) I like money.
4) Beer costs money.
5) So do condoms.
And there you have it, 5 totally awesome reasons for me to put a "donate" button on my blog, you dickheads. Now, stop bitching about it and give me your money already.
Caution: Non-geeks, please stop reading this post.
On a totally unrelated note, recently I was writing a program in C++ and I needed a function that does the reverse of atoi. As any programmer who happens to be reading this probably already knows, atoi converts a character ("1", "2", "3", "4", etc) to an integer value (1, 2, 3, 4, etc). I needed a function that converts an integer to its string representation. I googled for it, of course, and apparently there was already an "itoa" function in the header file < cstdlib>. I included it, but unfortunately, the g++ compiler still told me that the function did not exist. I googled some more, and apparently I had neglected to stick this in the code:
using std::itoa;
I did that, but the compiler still said nay. I was getting pissed by then, and I did not have the time to putter around looking for the function. I therefore wrote my own "itoa" function. Of course, it's a really simple function that any programmer will probably be able to write, but why waste time if you don't have to? So here it is, in case anyone needs to use it.
#include < iostream>
#include < string>
using namespace std;
string itoa(string, int);
main(){
int someInt;
string str="";
cout<<"Please enter an integer value: ";
cin>>someInt;
cout<<"You have entered " + itoa(str, someInt)< < endl;
}
string itoa(string str, int ref)
{
int remainder;
bool negative=false;
if(ref<0){
ref = ref * -1;
negative = true;
}
while(ref>=10){
remainder = ref % 10;
switch(remainder){
case 1: str = "1" + str;
break;
case 2: str = "2" + str;
break;
case 3: str = "3" + str;
break;
case 4: str = "4" + str;
break;
case 5: str = "5" + str;
break;
case 6: str = "6" + str;
break;
case 7: str = "7" + str;
break;
case 8: str = "8" + str;
break;
case 9: str = "9" + str;
break;
default: if(ref>=10)
str = "0" + str;
break;
}
ref = ref/10;
}
switch(ref){
case 1: str = "1" + str;
break;
case 2: str = "2" + str;
break;
case 3: str = "3" + str;
break;
case 4: str = "4" + str;
break;
case 5: str = "5" + str;
break;
case 6: str = "6" + str;
break;
case 7: str = "7" + str;
break;
case 8: str = "8" + str;
break;
case 9: str = "9" + str;
break;
}
if(str.length() == 0)
str = "0";
if(negative)
str = "-" + str;
return str;
}
This program basically takes an integer you enter as the input and outputs the string representation of that integer.