Tech Guide Blog

Tech Guide Programming Tutorial Tips Tricks

Archive for the ‘Tutorial’ Category

Stack C++ Data Structure Source Code

Posted by Admin On February - 7 - 2009

This time I will show you how to make a stack structure class with Visual C++, I do this with Visual C++ 6.0 Enterprise Edition. Just for info, stack is one of data structure types where data is somewhat placed on top of another data (stack). Adding or removing data can be done only on top of stack itself, last in first out. The adding is called push and getting or removing is called pop.
If you want to put a new data, it should be placed like this.

stack-illustration

stack illustration

then, if you want to get a data, it should return the last data you put on it (top of stack).

stack-illustration

stack illustration

pop-stack

Pop Stack

The third picture is stack after being popped out. Let’s get to the code then, juts make a header file (.h) and start typing. I will make a simple application that can keep integers with stack method.

//============== start of code ==============//
#include <stdio.h>
#include <conio.h>
#include <windows.h>

#define MAX 255

class cstack
{
private:
	int data[MAX]; // this is the place to keep
	int top; // to point the top of the stack
public:
	cstack() // constructor
	{
		top = 0;
	}
	void push(int value)
	{
		if (!full())
		{
			data[top] = value;
			top++;
		}
	}
	int pop()
	{
		if (!empty())
		{
			top--;
			return data[top];
		}
	}
	bool full()
	{
		if (top == MAX)
			return 1;
		else
			return 0;
	}
	bool empty()
	{
		if (top == 0)
			return 1;
		else
			return 0;
	}
	void view() // make a function to view the data
	{
		int i;
		printf("Just another stack data:n");
		for (i = 0; i < top; i++)
			printf("%d ", data[i]);
		getch();
	}
};
//=============== end of code ===============//

After you finished, you can make a C++ source file (.cpp) and can use that stack class that have you made.

//============== start of code ==============//
#include "header.h" // this must be the same place with your header file

void main()
{
	int choice, temp;
	cstack stack;

	do
	{
		system("CLS");
		printf("MENUn1. Pushn2. Popn3. Viewn4. ExitnChoice: ");
		scanf("%d",&choice);
		system("CLS");
		if (choice == 1)
		{
			printf("Value: ");
			scanf("%d",&temp);
			stack.push(temp);
		}
		else if (choice == 2)
			stack.pop();
		else if (choice == 3)
			stack.view();
	}
	while (choice != 4);
}
//=============== end of code ===============//

Save it and compile to try this simple application.

Popularity: 50% [?]

How to Make Own Send To Shortcut

Posted by Admin On January - 14 - 2009

Well, when we do right-click over a file, we can use Send To option to make it easier to transfer or copy a file. We can copy it to external drive, My Documents, desktop as a shortcut, or compressed folder, but we want another location that we use it frequently, like a favorite folder or another folders beside My Documents. I will show you how to do that.

  1. First step is make sure you unhide all files.

    unhide

    Unhide all files

  2. Go to C:Documents and SettingsXP. Remember, “C” is where is my Documents and Settings location and “XP” is my username, if you have another location and username, then open Documents and Settings folder in your computer and click your username folder. After that, you will see Send To folder, open it.

    sendto

    Send to

  3. Now, in this place, you can make a shortcut of your favorite folder or another folders that you feel necessary. For example, I make a shortcut of My mp3s folder, then after you make your shortcut, you can cut it and paste it in Send To folder.

    ownshortcut

    Place your shortcut here

  4. It’s done. You can hide your porn videos and forbidden files now :D. Like the picture below, now you can copy a file directly to your favorite folder, such a mp3 file or whatever you like.

    doneSendToShortcut

    Send to your shortcut

It’s simple, isn’t it? Make it easier to transfer files and less time to do instead of the normal one =).

Popularity: 7% [?]

How to be accepted by Google Adsense

Posted by Admin On December - 9 - 2008

Well, this issue is a classic problem with new blogger that want to make blog and make some money from internet. Here is my guide to help you guys:

  1. Make your blog with full-english language. This is basic term to be accepted, except google support your language.
  2. Make sure your blog/ site is not in under construction. Google won’t accept a demi-blog, this is business, you know what I mean? be serious.
  3. Make sure your blog do not contain any pornography and sexual explicit and whatever like that, you don’t need Adsense to earn money if your blog contain any sexual-things. You will get more gold from your content, right?
  4. Well, many people say if you create an account with gmail, it’s much easier than any e-mail account. So, why not ? Just create gmail account and sign up with that account.
  5. After you do 4 steps above, wait and see what happen.

Popularity: 14% [?]