Re: [algogeeks] C prog o/p

2012-10-15 Thread Shivam Rohilla
output will be 2 because of you subtract 2 addresses it gives (diffrence of addresses)/sizeof(datatype) (71-60)/4=2 On 13/10/2012, bharat b wrote: > #include > main() > { > int *i,*j; > i=(int*)60; > j=(int*)71; > printf("%d",j-i); > } > > -- > You received this message because you are subs

Re: [algogeeks] C prog o/p

2012-10-15 Thread Atul Singh
if u dereference these pointers.,, underlying os will not allow this. But in above 60 is stored in pointer varible. and that pointer variable is in the range of program memory. -- *ATul Singh** Software Engineer**, Interra Systems* Mobile : +91-9410826039 www.interrrasystems.com [image: Facebo

Re: [algogeeks] C prog o/p

2012-10-15 Thread Sairam Ravu
I think it allocates on each process's stack, so it is not an issue, as each process has got its own stack. On 10/15/12, bharat b wrote: > how can kernel agrees with this ? if we directly access address 60 .. which > is not in our control ... any malicious thing can happen right ? > > On Sun, Oct

Re: [algogeeks] C prog o/p

2012-10-15 Thread bharat b
how can kernel agrees with this ? if we directly access address 60 .. which is not in our control ... any malicious thing can happen right ? On Sun, Oct 14, 2012 at 5:39 PM, Dave wrote: > @Bharat: 0x notation indicates hexadecimal, so 0x11 = 1*16 + 1 = 17. > > Dave > > On Sunday, October 14, 201

Re: [algogeeks] C prog o/p

2012-10-14 Thread Dave
@Bharat: 0x notation indicates hexadecimal, so 0x11 = 1*16 + 1 = 17. Dave On Sunday, October 14, 2012 12:48:24 AM UTC-5, bharat wrote: > @Ashok : I didn't get this answer .. > i=0x3c --> what is this address .. variables has addresses but not the > values right? we are not storing 60 any wher

Re: [algogeeks] C prog o/p

2012-10-13 Thread Ashok Varma
(int *)60 => 60 is treated as address and 60 = 0x3c similarly 71 = 0x47 On Sun, Oct 14, 2012 at 11:18 AM, bharat b wrote: > @Ashok : I didn't get this answer .. > i=0x3c --> what is this address .. variables has addresses but not the > values right? we are not storing 60 any where right? > 0x11 =

Re: [algogeeks] C prog o/p

2012-10-13 Thread bharat b
@Ashok : I didn't get this answer .. i=0x3c --> what is this address .. variables has addresses but not the values right? we are not storing 60 any where right? 0x11 = 3 in decimal format not 11 base 10. typecasting to (int*) needs an address right? I mean int b=10; int * a=(int*)&b; On Sat, Oc

Re: [algogeeks] C prog o/p

2012-10-13 Thread Ashok Varma
This gives a clear explanation: #include main(){ int *i,*j; i=(int*)60; j=(int*)71; printf ("%p %p %d",i,j,j-i);} op: 0x3c 0x47 2 0x47 - 0x3c = 0x11 and hence j-1 = 2 (11/4 = 2, size of int = 4 bytes) On Sat, Oct 13, 20

[algogeeks] C prog o/p

2012-10-13 Thread bharat b
#include main() { int *i,*j; i=(int*)60; j=(int*)71; printf("%d",j-i); } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algog