Archive | April, 2010

Installing colorgcc in Ubuntu

14 Apr

Using the terminal and a simple text editor is my preferred method of writing code, regardless of the language its a fast and efficient method of testing code with running the overheads of an IDE on my little netbook. But deciphering errors has always been a pain as simple black and white error messages give eyestrain and are difficult to see.

Fortunately for the more tech-savvy they have the option of soft linking the colorgcc module to there compiler commands. But for the like of you and me its been a pain, atleast until quite by fluke I came across the following method of installing the module.

All you do is, go to terminal and type:

sudo apt-get install colorgcc

Thats it, it works wonders and now my error messages come in colour.

First Programs I’ve written

8 Apr

Recently, as in today while cleaning up my Code folder I can across a simple Hangman game that I had written a long time ago back when I was just completing my course in C++ and trying to make sense of it all.

Mind you it is very basic and needs a lot of work to make it more efficient and meet the standards required. So without further ado, cast your eyes down upon my very cool code :).

	Author: toughaspixels
	Purpose: To study and understand the use of STL ad Vectors
	Date: October 26th, 2009
	Modfied: April 7th, 2010
        License: Just let me know your using it please, feed my ego

using namespace std;

int main(){
    const int MAX_WRONG = 8;
    vector<string> words;
    random_shuffle(words.begin(), words.end());
    const string THE_WORD = words[0];
    int wrong = 0;
    string soFar(THE_WORD.size(), '-');
    string used = "";
    cout << "Welcome to HangMan. Good Luck!" << endl;
    while((wrong < MAX_WRONG) && (soFar != THE_WORD)){
        cout << "You have " << MAX_WRONG - wrong << " incorrect guesses left." << endl;
        cout << "You have used the following letters " << used << endl;
        cout << "So far, The word is:\n" << soFar << endl;
        char guess;
        cout << "\n\nEnter your guess: ";
        cin >> guess;
        guess = toupper(guess);
        while(used.find(guess) != string::npos){
            cout << "\nYou have already guessed " << guess << endl;
            cout << "Enter your guess: ";
            cin >> guess;
            guess = toupper(guess);
        used += guess;
        if(THE_WORD.find(guess) !=  string::npos){
            cout << "That's right! " << guess << " is in the word." << endl;
            for(int i = 0; i < THE_WORD.length(); i++){
                if(THE_WORD[i] == guess)
                    soFar[i] = guess;
            cout << "Sorry, " << guess << "is not in the word." << endl;
    if(wrong == MAX_WRONG)
        cout << "GAH!! GUH! NOOOOOooooooo\n Your hanged : ) HAHAHAHA" << endl;
        cout << "\nYou guessed it : ) Your awesome." << endl;
    cout << "\nThe word is " << THE_WORD << endl;
    return 0;

There you have it folks, enjoy.

Please feel free to use my code, just make sure I get credit or at the very least let me know whose using it.

%d bloggers like this: