C++

ProMec

Posted by Strainu on February 24, 2008
C++, Software / No Comments

Preview

ProMec is a small graphical project I did for the Mecanics course in the first year of faculty at UPB, with prof. A. Craifaleanu. It simulates the movement of a complex system made out of several bars.
Continue reading…

Share and Enjoy:
  • Facebook
  • Twitter
  • Identi.ca
  • LinkedIn
  • Reddit
  • Add to favorites

Tags: , ,

Talk

Posted by Strainu on February 24, 2008
C++, Software, WebBrowse / No Comments

Preview

Talk is a simple chat program. It uses the very simple Cesar code to encrypt the messages. Select the mode (client or server), the IP address and the port, then press “Conectare” ( “Asteapta” for the server), and, if there is another user, the message area will be activated.
Continue reading…

Share and Enjoy:
  • Facebook
  • Twitter
  • Identi.ca
  • LinkedIn
  • Reddit
  • Add to favorites

Tags: , ,

Query

Posted by Strainu on February 24, 2008
C++, Software, WebBrowse / No Comments

Preview

Query is a whois-like program that allows you to find the status of a domain or IP address. He uses Whois servers to obtain informations like the domain owner, expiration data, etc.

The software is distributed under CC-GNU GPL license.

Download (source)

Share and Enjoy:
  • Facebook
  • Twitter
  • Identi.ca
  • LinkedIn
  • Reddit
  • Add to favorites

Tags: , ,

The const keyword (part 2)

Posted by Strainu on May 29, 2007
C, C++ / No Comments

In part 1 we introduced the const keyword. Today we’ll talk about constant pointers.

Let’s say you want to define a constant pointer. Which of the following declarations will you use?

const int* v1;
int* const v2;
const int * const v3;

The answer is: the second or the third. The first declaration defines a pointer to a constant integer and the third one defines a constant pointer to a constant integer.

Another interesting case is when defining a constant char array (credits go to Ulrich Drepper, link via RazvanD):

int main(void)
{
const char s[] = "hello";
strcpy (s, "bye");
puts (s);
return 0;
}

Although this code will give a warning (passing `const char *’ as argument 1 of `strcpy(char *, const char *)’ discards qualifiers is the exact message on Dev-C++), it will run, because s is allocated in the heap, so it is treated much like a pointer. You can force the value to be constant by adding the static keyword, wich will force the compiler to allocate s in read-only memory:

static const char s[] = "hello";
Share and Enjoy:
  • Facebook
  • Twitter
  • Identi.ca
  • LinkedIn
  • Reddit
  • Add to favorites

Tags: ,

The const keyword (part 1)

Posted by Strainu on May 24, 2007
C, C++ / 1 Comment

This article will not actually present any tricks, it will be an introduction in the const keyword. In part 2, we will present the const and volatile pointers, which behave a little weird.

First of all, let’s see what the const modifier means in the C standard. Basically, a const variable is one who’s value can’t be changed. Actually, things are not so simple – as we’ll see later, you can change a constant variable. The standard states that “If an attempt is made to modify an object defined with a const-qualified type through use of an lvalue with non-const-qualified type, the behavior is undefined.” On some architectures, constant variables are put in a special section (sometimes called .rodata – from Read Only DATA) of the program by the compiler.

If you want to define a constant in C/C++, you can write:

const int v1 = 0; //the usual way
int const v2 = 1; //also legal

Both declarations mean the same thing: define a new integer with a fixed value. So, if you want to change the value of v1, how would you do it? By using pointers:

const int v1 = 0; //define a constant
int* v2 = &v1; //define a pointer to v1
*v2 = 5; //change the value

Of course, you shouldn’t do that, as the are no guarantees that the result will be what you expect it to be, but with most compilers, v1 will be 5 after running the code presented above.

Share and Enjoy:
  • Facebook
  • Twitter
  • Identi.ca
  • LinkedIn
  • Reddit
  • Add to favorites

Tags: ,

Digital/analogue clock

Posted by Strainu on August 24, 2006
C++, Software / No Comments

Preview

Digital/analogue clock A DevC++ program that shows an analogue or digital clock. The program shows the usage of classes in C++ and the usage of Windows drawing functions.
Continue reading…

Share and Enjoy:
  • Facebook
  • Twitter
  • Identi.ca
  • LinkedIn
  • Reddit
  • Add to favorites

Tags: , , ,

BlackJack (21)

Posted by Strainu on June 23, 2006
C++, Software / 2 Comments

Preview

BlackJack (21) is a simple simulation of a Black Jack game. Is shows the usage of bitmaps as background for MFC applications.
Continue reading…

Share and Enjoy:
  • Facebook
  • Twitter
  • Identi.ca
  • LinkedIn
  • Reddit
  • Add to favorites

Tags: ,

ThePlayZone

Posted by Strainu on June 23, 2006
C++, Software / No Comments

Preview

ThePlayZone is a simple mp3 player. It can read ID3v1 tags, the bitrate and frequency, and play m3u and pls playlists.
Continue reading…

Share and Enjoy:
  • Facebook
  • Twitter
  • Identi.ca
  • LinkedIn
  • Reddit
  • Add to favorites

Tags: ,

The “Tree” Class

Posted by Strainu on March 26, 2006
C++, Software / No Comments

The “Tree” Class A high-scool program to show the use of classes and trees represented in every possible way. It contains the following classes:arbore_m (trees represented by matrices); arbore_l (trees represented by lists); arbore_b (binary trees); arbore_cost (trees with costs).
Continue reading…

Share and Enjoy:
  • Facebook
  • Twitter
  • Identi.ca
  • LinkedIn
  • Reddit
  • Add to favorites

Tags: , ,

TicTacToe

Posted by Strainu on March 26, 2006
C++, Software / No Comments

Preview

TicTacToe is a program to simulate a TicTacToe game. There are 3 difficulty levels, from the one with no AI to the one where you can’t win. The program also has a scoreboard.
Continue reading…

Share and Enjoy:
  • Facebook
  • Twitter
  • Identi.ca
  • LinkedIn
  • Reddit
  • Add to favorites

Tags: ,