Posts

Showing posts from October, 2013

Stack Size : behind the code

How to know the stack size of a process in Linux? #Interview Question The stack word is very popular when it comes to C programming. It often intrigues us that how much is the stack size of a process and how to know it. The answer to this question can not be given without considering the "platform independent" thing. Well, we all are familiar with the word "platform independent". It is only word which comes to our mind when we don't know the answer. :P So, the stack size depends on the platform, the architecture - microprocessor is of how many bits - 16, 32, 64? But I will explain the answer with respect to Linux operating system. Method 1 The simplest method which I found is through cat /proc/-pid-/limits cat command is used to access a file. proc is a directory which contains information about all the running processes. -pid- is the process id of the process. We can know the process id of any process using ps -ef command. See man page of p...

error: invalid application of ‘sizeof’ to incomplete type ‘struct ’

list.c:47:39: error: invalid application of ‘sizeof’ to incomplete type ‘struct Litsnode’ So, I was trying to run a program based on linked list and this is what I got. This is a very silly problem. I am mentioning it here just to help those who got frustrated like me :-\ Let me show you the line where this error occurred : 46   struct Listnode * newnode; 47   newnode = (struct Listnode *) malloc(sizeof(struct Litsnode)); Now, View it properly. Check the name(spelling) of the structure mentioned to sizeof : " struct Li ts node ". Though the defined name of the structure was : " struct Listnode " That's it.  This happens all the time that we may type something wrong. The important thing is to identify it. :-) Feel free to give any suggestions :)