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
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
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
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
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
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
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
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
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
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
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
*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!
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
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
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,
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
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
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 ,
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
#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
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
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
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
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
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:
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
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
*#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
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;*
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
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
@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;*
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
#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
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
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
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};
@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
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
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
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
@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
@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
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[])
{
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
@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
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
@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
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
@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;
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;
51 matches
Mail list logo