Monday, September 23, 2013

const char * vs char * const

I came across the question 'What is the difference between const char * vs char * const many times. After trying several sample programs, here is a simple way to understand the differences. Let us see what char * means:
char * p; // defines a buffer where characters can be stored
          // returns a pointer that is pointing to the first element in the buffer and is denoted by p

When const is applied on char *, depending on the position of const,
different things happen on the buffer+pointer.
const char * p ->  buffer contents are a constant. Pointer variable p can be modified to point to a different buffer.
char * const p ->  buffer contents can be modified. Pointer variable p cannot be modified. p points to the same location, all the time.
const char * const p -> means that the buffer and the pointer cannot be modified

Summary:
DefinitionBufferPointer
const char * pCannot changeCan change
char * const pCan changeCannot change
const char * const pCannot changeCannot change

Saturday, September 14, 2013

Linux Commands

A list of Linux commands

How ToCommands
Disable Firewall $ service iptables stop # stops firewall $ chkconfig iptables off # disables firewall $ service iptables status # status of firewall

Friday, September 13, 2013

Renew IP Address

When computers are moved from one network to another network, its IP address changes. This change is not reflected immediately in network adapters. In order to force a reset of these adapters, the following commands are used.
Renew IP Address

Windows
1. Open a cmd prompt in elevated mode
2. Execute the command
    c:\windows\system32> ipconfig /renew


Linux
1. Open a Terminal as root
2. Execute the command
    $ ifconfig eth0 down
    $ ifconfig eth0 up