lionaneesh's Avatar, Join Date: Mar 2010
Invasive contributor
OS : Windows 7
Compiler : Code:Blocks
Compiled Without problem

Code:
0
1
4
9
16

Process returned 0 (0x0)   execution time : 1.110 s
Press any key to continue.
poornaMoksha's Avatar, Join Date: Jan 2011
Ambitious contributor
Can you give it a try on Unix/Linux ??
lionaneesh's Avatar, Join Date: Mar 2010
Invasive contributor
Quote:
Originally Posted by poornaMoksha View Post
Can you give it a try on Unix/Linux ??
Yeah Sure , I will! But can you explain me the reason why its giving error on Unix and not on Windows
poornaMoksha's Avatar, Join Date: Jan 2011
Ambitious contributor
I dunno why its not giving any error on windows but logically when we are about to call free(), we have incremented the address held at pointer 'p' (as we have used p++ many times in loop). Now when we do a free, then 'p' contains a different address than what malloc() gave it. So ideally the program should crash at free().
lionaneesh's Avatar, Join Date: Mar 2010
Invasive contributor
Quote:
Originally Posted by poornaMoksha View Post
I dunno why its not giving any error on windows but logically when we are about to call free(), we have incremented the address held at pointer 'p' (as we have used p++ many times in loop). Now when we do a free, then 'p' contains a different address than what malloc() gave it. So ideally the program should crash at free().
I know that and yeah regarding the windows issue , I think my compiler provides some support for preventing memory leak ! Thats why no errors!
lionaneesh's Avatar, Join Date: Mar 2010
Invasive contributor
Quote:
Originally Posted by poornaMoksha View Post
Did you even try to execute it??
Can u please explain my other problems too!
poornaMoksha's Avatar, Join Date: Jan 2011
Ambitious contributor
For problem '3', google how or rather in which order the function arguments are processed/passed when a function call is made.
hanleyhansen's Avatar, Join Date: Jan 2008
Pro contributor
This is good stuff. Are you going to provide the answer to all the questions eventually?
poornaMoksha's Avatar, Join Date: Jan 2011
Ambitious contributor
Quote:
Originally Posted by hanleyhansen View Post
This is good stuff. Are you going to provide the answer to all the questions eventually?
Thanks, I thought of having interactive sessions with different users on this article. If somebody comes up with some doubt/query then I'll definitely answer that but providing answers directly would defeat the purpose as of now. All I want is that anyone who finds these questions worth trying, should try them. Answers, doubts, queries can be discussed here.
It's a very interesting article.I like C program very much.So it's very helpfull to me.I can understand more programs&it's answer.