Archive for C++

Simple SMTP Client

Posted in C# with tags , , , , on October 25, 2010 by Xacker

In the Network Services course at the college I had to write a pseudo code to demonstrate how SMTP clients communicate with SMTP servers to send emails over SMTP protocol.

Since I hate writing a pseudo code for such simple application I’ve decided to use C# .NET


  1. The SMTP server is set up on a virtual machine, that explains the “”
  2. The SMTP clients doesn’t support secure communications for SMTP authentication, it was meant to be as simple as possible.
  3. I use Regular Expressions to run some validations and do Dot Stuffing that is required by SMTP if your Content-Transfer-Encoding was set to “7bit”

Continue reading

Finding a path in a maze using C++

Posted in Programming with tags , , on February 9, 2009 by Xacker

How to solve a maze with C++ ?

The following picture represents a simple maze of 10*10 blocks. Note that our program will take a maximum of 40*40 dimensions for example, this picture is only to simplify your imagination process 🙂
The maze will be represented by a 2 dimensional array.


Functions definitions:

  1. main() is the main program, that is used to call all other functions.
  2. setCoord() is an void type function, that takes 2 params, number of rows and cols of the the maze.
  3. fillMaze() is a void type function, that takes 3 params, a maze ptr, number of its rows and cols.
  4. valMaze() is an integer type function, that takes 5 params, a maze ptr, number of its rows and cols, an eNtry(x,y) ptr, an eXit(x,y) ptr.
  5. findPos() is an integer type function, that takes 5 params, a maze ptr, number of its rows and cols, (x,y) ptr, accum num.
  6. /* additional functions will be added later */

I’m gonna present the program as functions first then glue everything together at the end to avoid complixity.

I would like also to take this chance to thank the following people who have helped me a lot with this progress: خالد الشايع, TheNapsterBoy, علي الشمري, عمر العادل.

Caution: WordPress source code parser SUCKS, danger of falling asteroids! use helmets as precaution 😛

/*	gets the width and height of the maze
	checking for the allowed range */
void setCoord(int &nrows,int &ncols) {
	if (ncols < = 0 || ncols > 40) {
		printf ("Enter maze width: ");
		scanf_s  ("%d",&ncols);
	if (nrows < = 0 || nrows > 40) {
		printf ("Enter maze height: ");
		scanf_s  ("%d",&nrows);
	if (nrows < = 0 || nrows > 40 || ncols < = 0 || ncols > 40) {
		printf  ("Invalid width or height detected\n\n");
		setCoord(nrows,ncols);	// recursive call

Continue reading