Category Archives: Tech-Bowl

make one g-mail id … use multiples !!!

Hi all ,

Some days ago when I was sending a mail(G-mail to G-mail) to my friend , I just mistyped his id . Like if it was , I wrote Even after typing the  wrong e mail id , my mail was delivered to him . I wondered and then I did some searching on google regarding the same and I came to know about some interesting facts …

Suppose if I have gmail id : , then all following will work like my g – mail id –

1.   coolnandy+8 , here 8 char can be any valid set of characters .




As gmail ignores .’s in it’s username .

an alias made by mixture of various such alias is also an alias for your id.

like will alsodirect uts mail to your inbox.

You can use it to filter your e-mails from some sources by giving them aloas id and then using a filter with to field..

Leave a comment

Filed under Tech-Bowl

Some interesting C code …

Hello friends ,

I was just surfing the net late in night and then I came to see some interesting C codes . So here we go-

1) Suppose if one want to know the program name through the execution of code itself , then code for this is –


int main()


printf(“the source file name is %s\n”,__FILE__);

return 0;


What happens here in this program , __FILE__ is actually a macro which stands for the file name in which program is kept in.

Just use this keyword in the program and compiler will do the rest .

2) Suppose if we have a situation in a program where we are taking an input which is not going to be used then we have to use a variable to store that input like scanf(“%d”,&a) , means wastage of memory . But we have a technique to avoid this –

What we do for this , just use the scanf statement like this –


by using * here we force scanf to scan input from the standard input but it won’t assign to any variable .(This is scanned in a buffer of sufficient size and you don’t need to worry about that !

This section will be continued , wait for the next post !

Till then happy coding , 🙂


int main()
printf(“the source file name is %s\n”,__FILE__);
return 0;
int main()
printf(“the source file name is %s\n”,__FILE__);
return 0;

Leave a comment

Filed under Tech-Bowl

Little-Endianism and Big-Endianism , know what your system follow !!!

Hello friends ,

This is not a new thing for most of you , but still I am trying to enlighten this topic .

I’ll focus mainly on two things –

1.How can I determine whether a machine’s byte order is big-endian or little endian?
2. How can we convert from one to another?

For above queries , first you need to know Little Endian and Big Endian .

Little Endian means that the lower order byte of the number is stored in memory at the lowest address, and the higher order byte is stored at the highest address. That is, the little end comes first.

For example, a 4 byte, 32-bit integer
Byte3 Byte2 Byte1 Byte0
will be arranged in memory as follows:

Base_Address+0 Byte0
Base_Address+1 Byte1
Base_Address+2 Byte2
Base_Address+3 Byte3

Here base address may be any valid address of location .

Intel processors use “Little Endian” byte order. That’s why most of us use little endian systems .

Big Endian means that the higher order byte of the number is stored in memory at the lowest address, and the lower order byte at the highest address. The big end comes first.

Base_Address+0 Byte3
Base_Address+1 Byte2
Base_Address+2 Byte1
Base_Address+3 Byte0

Motorola, Solaris processors use “Big Endian” byte order.

Now with the help of following code you can find out that which endianism your system follow !

int main()
int num=1;
if(*(char *)&num==1)
printf(“System follows Little Endian \n”);
printf(“System follows Big Endian \n”);

return 0;


So friends run this code on your machine .

Now for second query we have a function which converts a number from one endian to another .

And here we go –

int convert_endian(int a)
int byte0,byte1,byte2,byte3;
byte0=(a & 0x000000ff)>>0;
byte1=(a & 0x0000ff00)>>8;
byte2=(a & 0x00ff0000)>>16;
byte3=(a & 0xff000000)>>24;
return (byte0<<24 | byte1<<16|byte2<<8|byte3<<0);

The explanation of this code –

Code assumes 32 bit architecture and store all the bytes (4 in number) into separate temporary integers .. also ensure to have all the 8-bits are at their LSB’s
now return the number formed by concatenating of byte’s in reverse order .. this has been achieved in the code by ORing the various bytes shifted to the appropriate positions.

Hope this will help you to know your system better ! 🙂

Leave a comment

Filed under Tech-Bowl

Byte packing !

Hello friends ,

I was studing C++ late in night and I faced a little weird situation . I saw a code as follows:

class check
int i;
float j;
char k;
int main()
check c;
return 0;

As I was expecting the output 9,9 , but it didn’t give the same on my linux machine.

And then I came to know that byte packing is done here .

Linux  being a 32-bit OS , so the object would be aligned on a 4-byte boundary.

Hence I got the output 12,12.

Isn’t it memory consuming ?

Well , we can overcome from this situation by using pragma.

We can force the alignment on a 1-byte boundary. To do this , we have to use

#pragma pack(1)  just before the class declaration.But friends , one more thing is still left, you can’t use #pragma pack with any random number. The number in the paranthesis must be a small power of two. Otherwise you may get the warning stating the same.

So don’t wait , open your text editor and try this . ♥

Leave a comment

Filed under Tech-Bowl

Conversion operator

Hello squids ,

Many of you ,who are studing/studied C++ , may be aware of conversion operator.

In short it may be described as :

A conversion operator can be thought of as a user-defined typecasting operator; it converts its object to a different type in contexts that require that specific type.

And that specific type may be built in as well as user defined .

I like this feature because of the flexibility that it provides to this programming language.

Here I am giving an example which will help you for better understanding of this operator.

class Mystring
char *s;
int size;
Mystring(const char *);
operator const char * () { return s; }

int main()
Mystring str(“hello world”);
int n = strcmp(str, “Hello”);
return 0;

In this example constructor is taking argument const char * and in main “hello world” is passed as an argument in the object.But in next line we are trying to compare a string with an object, which will cause an error , if we don’t use the conversion operator.

So , here conversion operator comes in action and it converts the object into a constant string.

The prototype of conversion function is –

operator type()   {return value;}

here value is the value of class after conversion .type is the data type in which object is to be converted .

Conversion operators differ from ordinary overloaded operators in two ways. First, a conversion operator has no return value (not even void). The return value is inferred from the operator’s name. Secondly, a conversion operator takes no arguments. Conversion operators can convert their objects to any given type, fundamental and user-defined.

Hope this’ll help you guys .

Leave a comment

Filed under Tech-Bowl