Invasive contributor
3Oct2011,07:12   #11
lionaneesh's Avatar
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.
Ambitious contributor
3Oct2011,07:14   #12
poornaMoksha's Avatar
Can you give it a try on Unix/Linux ??
Invasive contributor
3Oct2011,07:16   #13
lionaneesh's Avatar
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
Ambitious contributor
3Oct2011,07:19   #14
poornaMoksha's Avatar
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().
Invasive contributor
3Oct2011,18:23   #15
lionaneesh's Avatar
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!
Invasive contributor
3Oct2011,18:30   #16
lionaneesh's Avatar
Quote:
Originally Posted by poornaMoksha View Post
Did you even try to execute it??
Can u please explain my other problems too!
Ambitious contributor
3Oct2011,18:40   #17
poornaMoksha's Avatar
For problem '3', google how or rather in which order the function arguments are processed/passed when a function call is made.
Pro contributor
12Oct2011,17:53   #18
hanleyhansen's Avatar
This is good stuff. Are you going to provide the answer to all the questions eventually?
Ambitious contributor
12Oct2011,17:58   #19
poornaMoksha's Avatar
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.
Banned
21Nov2011,15:51   #20
jyothishwebtech's Avatar
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.