Strainu onLine
Blogul unui automatist
1st
MAY
Zero-extent array members
Posted by Strainu | Filed under C
Some compilers, such as GCC or IBM’s compiler have a C extension that allows for a zero-extent array members of a structure to be declared:
//other members
char data[0];
};
They are very useful if you have a structure for a variable-length object. Until they are allocated the zero-extent members will not take up any memmory. When you have to allocate memory for such a structure, you can do it this way:
struct inode *ind = (struct inode*) malloc(sizeof(struct inode) + size_of_the_array);
You have to keep in mind that this is a language extension. The C99 standard only allows flexible array members, which are defined as
char array[];
(without the 0) and behave somewhat differently. You can find out more about the subject in the GCC Manual.
1st
New blog – Coder Tricks
Posted by Strainu | Filed under Geeks, My Projects, Personal, School
With the help of some colleagues, I just launched a new blog. It’s called Coder Tricks and it will contain programming tricks that the teachers don’t usually bother to tell you in programming courses. Hope you like it!
If you wish to offer any kind of feedback, you’re more than welcomed to contact us at codertricks@strainu.ro.
Recent Posts:
- 28 Oct Some people just won̵...
- 18 Aug Wiki Loves Monuments RomÃ...
- 15 May Want to work on Pidgin or...
- 14 Apr Free WiFi in the metro!
- 04 Apr Libertatea dincolo de sof...
- 11 Feb Electrocasnice online: Do...
- 15 Oct Wikipedia română –...
- 14 Oct Veliko Tarnovo Sound ...
- 11 Oct Romanian Postal Codes in ...
- 11 Jul Wikimania 2010 – zi...