Please explain a example from knr book
I am going through this book and i m getting confused with one program which i am copy/pasting below .
Code:
#include <stdio.h> for i =0 then power function is called power(2,0) =1 then i=1 power(2,1)=2 then i=2 in power(2,2) first p(2,1) =2 second p(2,2) =4 then i=3 int power(2,3) first p(2,1) =2 second p(2,2) =4 third p(2,3)=8 it should print for each case . and by doing this it should generate duplicate copies but it is not happening . Please explain the reason for same. |
sorry guy, it should generate duplicate copies of what? Please explain what do you expect!
|
Hi batman4!
It's been many years since I had a copy of K&R around. So unfortunately, I can't just look up the example. As has been mentioned by pan64, from what you've said, it doesn't seem entirely clear, what you're expecting, especially when compared to the code you've shown us. I'm hoping that the most important thing to you, is to get output similar to what you've shown is. So I've included here, code modified to produce output somewhat like what you've shown us. Even then, the output that you've shown us, doesn't appear to me, to be entirely consistent even with itself. But I hope that what I've shown you here, helps you understand the problem better. Here's the code after I modified it: Code:
#include <stdio.h> Code:
|
Quote:
Now look at this way with proper quotes:- Quote:
PS : Learning gdb to debug C codes will be a good idea. Lots of things get clear. :) Regards. |
All times are GMT -5. The time now is 07:59 AM. |