Archive for October, 2012

a continuation to the post

const char *p,**p2;
char *c,**c2;
p=c; //no warning
c=p; //warning a const pointer to a non const pointer
c2=p2; //warning incompatible type pointer assignment
p2=c2; //warning incompatible type pointer assignments

Explanation :
p=c -> in this assignment all the attributes of RHS are retained with an extra attribute (const) added hence no warning
c=p -> in this assignment, RHS loses one of its attribute
c2=p2 / p2=c2 -> in this assignment, both c2 and p2 are the pointers to pointers and C does not carry the compatibility of pointers associatively to next level and hence incompatible pointer assignment


if( -1 < (unsigned int) (1) )
printf("ANSI C\n");
else
printf("K & R C\n");

Output of the above code is : “K & R C”
Acc. to ANSI standards, signedness of the operands is retained while acc. to K & R C, if either operands is unsigned, conversion is unsigned. hence it really becomes a compiler specific problem and hence whenever you want to obtain a consistent result out of these kind of codes, use specific type casted conversions.

 

[update]

Flexible Size Array
In a structure, you can have the last element as a size zero element. It helps to have the flexible sized array.
struct myStruct
{
int length;
int arr[0]
}myStruct_t;
myStruct_t *ms = malloc (sizeof(myStruct) + size * (sizeof(int)));
ms->length = size;

Here element arr of myStruct can have size no. of elements.
More details:
http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

Happy programming.

http://phys.org/news/2012-10-cloud.html

Here comes the good news for the ARM developershttp://www.zdnet.com/one-linux-for-all-arm-systems-7000005348/

On 19th sep, i started my train journey towards my home to spend my vaccations. I love trains though while saying this i might sound like sheldon but i love trains because of a whole together different reasons. A train journey if long enough gives you enough time to think about different aspects of your life. This time while reading the dan brown’s the lost symbol, it invoked a chain of thought process inside me towards what i really want from life, where my life is going, are there things meant to be done by me, about world surrounding us and it continued on various other questions. Sitting in the midway of the train’s gate or sitting aside the window seat, i did a lot of thinking about these questions. Found the answer of some(which i am not going to discuss here) and some quests are still hunting there answers but i must say that everyone should do such practice once in a while questioning yourself with these kind of questions. It really brings a great deal of peace to the mind and also tells us about where to correct ourselves in our course of actions. Currently i am enjoying vaccations at home and trying to infuse the things i have thought for myself.