JustKernel

Ray Of Hope

Basic C

Function Pointer/ Pointers to Function

Pointers to Function / Function Pointers. A useful technique is the ability to have pointers to functions (Specially useful in case of implemening State Machine ). Suppose you declare int func (int , int); The pointer to a function will look like int (*funcptr)(int a, int b ) //pointer to a funtion returning int. Note: […]

Tags:

Posted in Basic C | No Comments »

Basic C – Keep learning..

Today I faced a rather simple problem for which , though I was sure of finding a solution, I couldn’t find a solution. I had a struct organized as struct { unsigned short msg_id; char *data; }tmp; struct tmp st_data; unsigned short var; Now I needed to extract the first two bytes from the structure […]

Posted in Basic C | No Comments »

Structure Padding

Today I learnt a new thing regarding padding. I was programming for Octeon board and using MIPS 64 bit compiler. I was reading the content from the file in the following order uint32 a; uint32 b; uint 16 c; uin8 d; fscanf(“%lu, %lu, %u,%c”, &a, &b, &c, &d) file content (10,20,30,40); But to my surprise, […]

Tags:

Posted in Basic C | No Comments »