[algogeeks] Pointer

2011-08-30 Thread Nikhil Gupta
I read a question : To swap two given strings using pointers. Are we supposed to declare two pointers and exchange their values, or use these pointers to swap each element of the two strings one by one? -- Nikhil Gupta NSIT, New Delhi, India -- You received this message because you are

Re: [algogeeks] Pointer

2011-08-30 Thread sagar pareek
Just refer indirect sorting...its just like what u guessed :) On Tue, Aug 30, 2011 at 11:33 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: I read a question : To swap two given strings using pointers. Are we supposed to declare two pointers and exchange their values, or use these pointers

[algogeeks] pointer query

2011-08-27 Thread raj kumar
what's the difference between char* p and *char p Source samsung inteview I think the second one is invalid please also tell can we use expression of second form anywhere thanks -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] pointer query

2011-08-27 Thread sukran dhawan
invalid On Sat, Aug 27, 2011 at 8:13 PM, raj kumar megamonste...@gmail.com wrote: what's the difference between char* p and *char p Source samsung inteview I think the second one is invalid please also tell can we use expression of second form anywhere thanks -- You received this

Re: [algogeeks] Pointer Question

2011-08-12 Thread Sachin Jain
Explanation please On Fri, Aug 12, 2011 at 9:33 AM, Dipankar Patro dip10c...@gmail.com wrote: b. On 11 August 2011 23:20, arvind kumar arvindk...@gmail.com wrote: b. On Thu, Aug 11, 2011 at 11:18 PM, Mani Bharathi manibharat...@gmail.comwrote: int(* fun()) [row][ Col]; What

Re: [algogeeks] Pointer Question

2011-08-12 Thread Prem Krishna Chettri
Ideally Speaking all of the option here seems not matching as this is the function pointer not an ordinary pointer. So the closest match is b but actually its not pointing to any 2 D or 3 D array or somewhat but rather it points to the block of memory starts from the dynamic address of row and

[algogeeks] Pointer Question

2011-08-11 Thread Mani Bharathi
int(* fun()) [row][ Col]; What should be the statement the for the above declarations a.fun() points to a two dimensional array b.pointer *fun() points to a two dimensional array c.pointer *fun() points to 1-dimensional array -- You received this message because you are subscribed to the Google

Re: [algogeeks] Pointer Question

2011-08-11 Thread arvind kumar
b. On Thu, Aug 11, 2011 at 11:18 PM, Mani Bharathi manibharat...@gmail.comwrote: int(* fun()) [row][ Col]; What should be the statement the for the above declarations a.fun() points to a two dimensional array b.pointer *fun() points to a two dimensional array c.pointer *fun() points to

Re: [algogeeks] Pointer Question

2011-08-11 Thread Dipankar Patro
b. On 11 August 2011 23:20, arvind kumar arvindk...@gmail.com wrote: b. On Thu, Aug 11, 2011 at 11:18 PM, Mani Bharathi manibharat...@gmail.comwrote: int(* fun()) [row][ Col]; What should be the statement the for the above declarations a.fun() points to a two dimensional array

Re: [algogeeks] pointer size

2011-08-06 Thread Shashank Jain
dipankar, i hv 64 bit OS nd 32 bit compiler only since the ptr variable shows 4 bytes only. So how is dat possible acc. to what u said earlier? Shashank Jain IIIrd year Computer Engineering Delhi College of Engineering On Thu, Aug 4, 2011 at 7:33 PM, Ashish kumar Jain

Re: [algogeeks] pointer size

2011-08-06 Thread Shashank Jain
sorry i read it wrong. u are right! Shashank Jain IIIrd year Computer Engineering Delhi College of Engineering On Sat, Aug 6, 2011 at 6:51 PM, Shashank Jain shashan...@gmail.com wrote: dipankar, i hv 64 bit OS nd 32 bit compiler only since the ptr variable shows 4 bytes only. So how is dat

Re: [algogeeks] pointer size

2011-08-06 Thread Shashank Jain
*sizeof* is compiler and processor dependent for reasons of both architectural limitations and efficiency. Shashank Jain IIIrd year Computer Engineering Delhi College of Engineering On Sat, Aug 6, 2011 at 6:52 PM, Shashank Jain shashan...@gmail.com wrote: sorry i read it wrong. u are right!

Re: [algogeeks] pointer size

2011-08-04 Thread Dipankar Patro
there absolutely nothing wrong in your interpretation. here is a link that might help : http://www.unix.org/whitepapers/64bit.html On 4 August 2011 11:18, Shashank Jain shashan...@gmail.com wrote: see dipankar, i hv 64 bit OS nd processor bt i dont know abt the compiler. nd yeah size of int

Re: [algogeeks] pointer size

2011-08-04 Thread Shashank Jain
man this is too big of a page to go thru... so tell as both (OS nd pro) are 64 bit why is ptr size 4 bytes? nd also does it depend on all 3 : OS, processor, compiler ? Shashank Jain IIIrd year Computer Engineering Delhi College of Engineering On Thu, Aug 4, 2011 at 11:57 AM, Dipankar Patro

Re: [algogeeks] pointer size

2011-08-04 Thread Dipankar Patro
For simple answer: yes. All must be compatible with 64 bit data/address handling. On 4 August 2011 12:02, Shashank Jain shashan...@gmail.com wrote: man this is too big of a page to go thru... so tell as both (OS nd pro) are 64 bit why is ptr size 4 bytes? nd also does it depend on all 3 : OS,

Re: [algogeeks] pointer size

2011-08-04 Thread N1teesh
So if either of the OS , Compiler , Processor are 32 Bit , then the size is bound to be 4 bytes? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] pointer size

2011-08-04 Thread Dipankar Patro
Yeah. On 4 August 2011 12:14, N1teesh nitee...@gmail.com wrote: So if either of the OS , Compiler , Processor are 32 Bit , then the size is bound to be 4 bytes? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on

Re: [algogeeks] pointer size

2011-08-04 Thread Dipankar Patro
Also, you must remember that 64 OS can never run 32 bit Processors, since it will require a 64 bit CPU to produce a 64bit address format On 4 August 2011 19:19, Dipankar Patro dip10c...@gmail.com wrote: Yeah. On 4 August 2011 12:14, N1teesh nitee...@gmail.com wrote: So if either of the OS ,

Re: [algogeeks] pointer size

2011-08-04 Thread Ashish kumar Jain
Just check if you have installed DEV Cpp win32 installation or not.That will confirm the usage and observation.As per the Dev cpp page it is available in 32 bit exe only. On Thu, Aug 4, 2011 at 7:21 PM, Dipankar Patro dip10c...@gmail.com wrote: Also, you must remember that 64 OS can never run

[algogeeks] pointer question

2011-08-04 Thread Vijay Khandar
#includestdio.h #includeconio.h void main() { clrscr(); float a=5.375; char *p; int i; p=(char *)a; for(i=0;i=3;i++) printf(%02x,(unsigned char)p[i]); getch(); } O/P-00 00 AC 40 Plz anyone explain me output. Vijay -- You received this message because you are subscribed to the

[algogeeks] pointer size

2011-08-03 Thread Shashank Jain
the size of a pointer is showing 4 bytes in my 64-bit OS, which should have been 8 bytes. Correct me where i am wrong? Shashank Jain 3rd year, Computer Engg. Delhi College of Engineering -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] pointer size

2011-08-03 Thread Tushar Bindal
never assume that he compiler is same as the OS you run. it may be that you are running a 32-bit compiler I think pointers have size 4bytes on 8 byte compiler also - not sure. someone please correct me. On Thu, Aug 4, 2011 at 10:26 AM, Shashank Jain shashan...@gmail.com wrote: the size of a

Re: [algogeeks] pointer size

2011-08-03 Thread Shashank Jain
tush, u hv ny idea dev c uses which compiler? Shashank Jain 3rd year, Computer Engg. Delhi College of Engineering On Thu, Aug 4, 2011 at 10:38 AM, Tushar Bindal tushicom...@gmail.comwrote: never assume that he compiler is same as the OS you run. it may be that you are running a 32-bit

Re: [algogeeks] pointer size

2011-08-03 Thread Dipankar Patro
This has been a hot topic of discussion for a long time. But I found there are two things to look into it: 1. a 64 bit OS is one, which has 64 bit address handling capacity. and a 64bit processor is one which can perform operations on 64 bit data. A general concept that actually gets overlooked

Re: [algogeeks] pointer size

2011-08-03 Thread Shashank Jain
see dipankar, i hv 64 bit OS nd processor bt i dont know abt the compiler. nd yeah size of int is 4 bytes. so tell me where im interpreting wrong? Shashank Jain 3rd year, Computer Engg. Delhi College of Engineering On Thu, Aug 4, 2011 at 11:16 AM, Dipankar Patro dip10c...@gmail.com wrote:

[algogeeks] Pointer

2011-07-31 Thread Nikhil Gupta
How to swap two pointers without using a temporary pointer ? -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

Re: [algogeeks] Pointer

2011-07-31 Thread pandharinath gorde
use xor ing for the same On Sun, Jul 31, 2011 at 7:15 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: How to swap two pointers without using a temporary pointer ? -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- You received this

Re: [algogeeks] Pointer

2011-07-31 Thread rajeev bharshetty
*#includestdio.h* *int main()* *{* *int i=10;* *int j=20;* *int *a,*b;* *a =i;* *b=j;* *printf(before%d%d\n,*a,*b);* **a^=*b;* **b^=*a;* **a^=*b;* *printf(after%d%d,*a,*b);* *return 0;* *}* * * *This swaps pointers * On Sun, Jul 31, 2011 at 7:15 PM, Nikhil Gupta

Re: [algogeeks] Pointer

2011-07-31 Thread Nikhil Gupta
Whats the logic behind **a^=*b;* **b^=*a;* **a^=*b;* ?? On Sun, Jul 31, 2011 at 7:19 PM, rajeev bharshetty rajeevr...@gmail.comwrote: *#includestdio.h* *int main()* *{* *int i=10;* *int j=20;* *int *a,*b;* *a =i;* *b=j;* *printf(before%d%d\n,*a,*b);* **a^=*b;* **b^=*a;* **a^=*b;*

Re: [algogeeks] Pointer

2011-07-31 Thread Nikhil Gupta
http://ideone.com/YHxVe @Rajeev, check this. On Sun, Jul 31, 2011 at 7:28 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: Whats the logic behind **a^=*b;* **b^=*a;* **a^=*b;* ?? On Sun, Jul 31, 2011 at 7:19 PM, rajeev bharshetty rajeevr...@gmail.comwrote: *#includestdio.h* *int

Re: [algogeeks] Pointer

2011-07-31 Thread Surya Prakash
suppose if we want to swap 3 and 5 *a=3 *b=5 then, 1st xoring *a and *b and copying back to *a *a=011 *b=101 *a=110 2nd-- *b^=^a --- *b=101

Re: [algogeeks] Pointer

2011-07-31 Thread rajeev bharshetty
@Nikhil : What do you want to convey ?? On Sun, Jul 31, 2011 at 7:32 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: http://ideone.com/YHxVe @Rajeev, check this. On Sun, Jul 31, 2011 at 7:28 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: Whats the logic behind **a^=*b;* **b^=*a;*

[algogeeks] pointer access in c++

2011-07-28 Thread mohit verma
hey guys, One simple example: class A{ int a,b; public: A():a(2),b(3){} }; class B:public A { public: int c; }; int main() { B ob; int *ptr=ob.c; cout*ptr; ptr--; cout*ptr; ptr--; cout*ptr; return 0; } AFAIK, inheritance in any visibility mode does not provide access to

[algogeeks] pointer increment problem can anyone tell why this output is coming?

2011-07-02 Thread Deoki Nandan
#includeiostream using namespace std; int main() { int intArray[]={1,2,3}; int *p=intArray; cout*(p++); return 0; } output : 1 -- **With Regards Deoki Nandan Vishwakarma * * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] pointer increment problem can anyone tell why this output is coming?

2011-07-02 Thread vaibhav shukla
ptr is pointing to array. *(ptr++) will give ptr and *ptr will give 1,further ptr will be incremented and will point to 2. On Sat, Jul 2, 2011 at 10:17 PM, Deoki Nandan deok...@gmail.com wrote: #includeiostream using namespace std; int main() { int intArray[]={1,2,3}; int

Re: [algogeeks] pointer increment problem can anyone tell why this output is coming?

2011-07-02 Thread Deoki Nandan
yes thanx a lot . becoz there is no sequence point and there is post increment operator is used . On Sat, Jul 2, 2011 at 10:22 PM, aditya kumar aditya.kumar130...@gmail.comwrote: though you have put bracket over pointer but it will still be defrenced first and then the pointer will increemnet

Re: [algogeeks] pointer and array

2010-08-03 Thread Raj N
array is passed a pointer in the function, hence sizeof(arr)==sizeof(*arr) On Fri, Jul 23, 2010 at 9:10 PM, tarak mehta tarakmeht...@gmail.com wrote: int arr[]={1,2,3,4}; k=sizeof(arr)/sizeof(*arr); value of k=4; however void hell(int arr[]); main() { int arr[]={1,2,3,4};

Re: [algogeeks] pointer and array

2010-07-25 Thread padmanaban sahadevan
@tarak mehta: if u wanna understand, try passing a char array to a function n do de same... On Sun, Jul 25, 2010 at 9:59 AM, Manjunath Manohar manjunath.n...@gmail.com wrote: @Apporve... yeah u r right :)sizeof ptr is always 2 in 16 bit compilers, i.e, the sizeof an address is 2.and the

Re: [algogeeks] pointer and array

2010-07-24 Thread jalaj jaiswal
sizeof(arr) is 4.. o.e the number of elements in the array size of *arr is the size of any normal pointer i.e 4(in case of 32-bit compilers) so the answer is 1 On Sat, Jul 24, 2010 at 9:52 AM, ravi gupta ravikant0...@gmail.com wrote: On Sat, Jul 24, 2010 at 9:40 AM, tarak mehta

Re: [algogeeks] pointer and array

2010-07-24 Thread Manjunath Manohar
when arrays are passed as arguments to a function,the starting address of the array is passed like a pointer, thus sizeof(arr)=2..thus 2/2=1..this is the precise reason for always specifying the column length in the definition of function when functions have arrays as one of the arguments.. Hope

Re: [algogeeks] pointer and array

2010-07-24 Thread tarak mehta
void hell(int arr[]); main() { int arr[]={1,2,3,4,5}; hell(arr); } void hell(int arr[]) { printf(%d,sizeof(arr)/sizeof(*arr)); } even this gives 1 !! @manjunath ur idea seems correct..but could u plz elaborate a bit On Sat, Jul 24, 2010 at 10:51 PM, Manjunath Manohar

Re: [algogeeks] pointer and array

2010-07-24 Thread Apoorve Mohan
@tarak: You can see it like this. When we create an array then 'a' points to the whole array not just the first element so it returns the size of the whole array. when you pass the array though by default in c it is pass by value but as you are passing the address of the array so it acts like

Re: [algogeeks] pointer and array

2010-07-24 Thread Manjunath Manohar
@Apporve... yeah u r right :)sizeof ptr is always 2 in 16 bit compilers, i.e, the sizeof an address is 2.and the sizeof(int)=2..i.e sizeof(*arr)=2..hope u got it now.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] pointer and array

2010-07-23 Thread ravi gupta
On Sat, Jul 24, 2010 at 9:40 AM, tarak mehta tarakmeht...@gmail.com wrote: int arr[]={1,2,3,4}; k=sizeof(arr)/sizeof(*arr); value of k=4; however void hell(int arr[]); main() { int arr[]={1,2,3,4}; hell(arr); } void hell(int arr[]) {

Re: [algogeeks] Pointer to a constant

2010-06-08 Thread divya jain
i think both statements shd give error. as u r trying to change int to const int in 2 and const int to int in 1.. On 7 June 2010 19:59, mohit ranjan shoonya.mo...@gmail.com wrote: @Raj, no they are not same case 1: i is const case 2: ptr is const and whatever is const cann't be modified

Re: [algogeeks] Pointer to a constant

2010-06-08 Thread Raj N
@Mohit: If u're saying that in case 2 ptr is const then what is int *const ptr. I thought this is a constant pointer. Constant pointer is one which can't be made to point to any other address rit? How is *ptr++ coming into the way of constant pointer ? On Mon, Jun 7, 2010 at 7:59 PM, mohit ranjan

Re: [algogeeks] Pointer to a constant

2010-06-08 Thread Raj N
Actually the first statement i gave const int i=5; int *ptr=i is itself giving an error on gcc and a warning on borland. We have to modify it as const int *ptr=i otherwise it gives illegal pointer conversion error. On Tue, Jun 8, 2010 at 12:11 PM, divya jain sweetdivya@gmail.comwrote: i

Re: [algogeeks] Pointer to a constant

2010-06-08 Thread mohit ranjan
@Raj, Sorry for the confusion yes, you are right that 1st one is giving warning/error though for 2nd case int i=5; const int *ptr=i; *ptr++; i am nt getting any error/warning (gcc) and i remains 5 but int i=5; const int *ptr=i; (*ptr)++; is giving error Mohit Ranjan On Tue, Jun 8, 2010

[algogeeks] Pointer to a constant

2010-06-07 Thread Raj N
Can someone tell me the difference between 1) const int i=5; 2) int i=5; int *ptr=i; const int *ptr=i; In the first case i can be modified via ptr i.e *ptr++ is valid. In the second case *ptr++ is illegal. Why is that so? Aren't

Re: [algogeeks] Pointer to a constant

2010-06-07 Thread mohit ranjan
@Raj, no they are not same case 1: i is const case 2: ptr is const and whatever is const cann't be modified Mohit Ranjan On Mon, Jun 7, 2010 at 3:01 PM, Raj N rajn...@gmail.com wrote: Can someone tell me the difference between 1) const int i=5; 2) int i=5;

Re: [algogeeks] Pointer to a constant

2010-06-07 Thread Raj N
1) const int i=5;2) int i=5; int *ptr=i; const int*ptr=i; On Mon, Jun 7, 2010 at 3:01 PM, Raj N rajn...@gmail.com wrote: Can someone tell me the difference between 1) const int i=5;