02 June, 2011

Simple one!!!!!!

Whats the difference between "typedef"s and MACROs(#define)????

02 May, 2011

Const pointer Vs Pointer to a const

Does any one remember the difference between constant pointer and pointer to a constant.

I have three declaration:

const int *ptr;
int const *ptr;
int *const ptr;










28 April, 2011

Representing binary in C code

Hi all

    It has been a long time... :)

    Hey does any one know if it is possible to add prefix before a number to represent binary

    For example
        unsigned char a = 0xF0;    This is for hexadecimal
       
Is there a similar representation for binary and octal?
I already tried

    unsigned char a = 0b11110000;

It is possible in MPLAB but not with gcc on linux.
Any solutions...???



20 March, 2011

Useful tips in VIM Editore.

1. If you want to split the screen horizontally give command
:split
If you want to split the screen vertically give command
:vsplit
If you want to open an new/other exiting file in splited window give command
:new filename for horizontal window
:vnew filename for vertical window.
If you want to quit all window give command
:qall for quitting without saving the changes
:wqall for quitting with saving the changes
You can use normal quitting command for one particular splitted window like
q,wq
To move between the splitted window , use ctrl+ww

2. Folding techniques:
You can fold a block of code of a long file. The block can be anything like (),{},[]
or may be some code between the lines.
For example:
Suppose this is your code:
#include
.........................
.......
int main(void)
{
----
----
----
for(;;){

-----
-----
}
}

To fold the brackets {} of for loop, keep the cursor at opening bracket of the for loop and then use zfa} command. It will make a fold till the closing of the corresponding bracket. This technique also works form backward.
It means you can keep the cursor at the closing bracket and use command zfa{ .
For closing and opening the folds, move the cursor at the fold and use command za
If you want to fold the codes between particular lines , Use command
:beginning_line,closing_line fold
Give a space between closing line and fold command.You can also use fo instead of fold.

For more details about this folding option just visit the link.
http://www.linux.com/archive/feature/114138

17 March, 2011

Puzzle

You are given two ropes and a lighter. This is the only equipment you can use. You are told that each of the two ropes has the following property: if you light one end of the rope, it will take exactly one hour to burn all the way to the other end. But it doesn’t have to burn at a uniform rate. In other words, half the rope may burn in the first five minutes, and then the other half would take 55 minutes. The rate at which the two ropes burn is not necessarily the same, so the second rope will also take an hour to burn from one end to the other, but may do it at some varying rate, which is not necessarily the same as the one for the first rope. Now you are asked to measure a period of 45 minutes. How will you do it?