memcpy() Behaviour
myhotline_at_gmail.com
Date: 12/30/04
- Next message: Mark Gordon: "Re: using 8086 in C"
- Previous message: Old Wolf: "Re: problem abt printf on Turboc"
- Next in thread: Ben Pfaff: "Re: memcpy() Behaviour"
- Reply: Ben Pfaff: "Re: memcpy() Behaviour"
- Reply: Michael Mair: "Re: memcpy() Behaviour"
- Reply: Jonathan Bartlett: "Re: memcpy() Behaviour"
- Reply: Barry Schwarz: "Re: memcpy() Behaviour"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Dec 2004 13:57:56 -0800
hi all
im very confused about using memcpy and i have three
questions....memcpy takes a pointer to src and a pointer to dest and
copies src to destination...but im very confuzed about when to use '&'
operator while using memcpy....i have code that use '&' and the code
that call memcpy without '&'
like is the following same
Quest1
---
struct str{
int name;
}
struct stru{
int aname;
}
str *s;
s->name = 10;
stru *s1;
s1->aname = 100;
//now what about following two lines
memcpy(s->name,s1->aname,sizeof(int));
memcpy(&(s->name),&(s1->aname),sizeof(int));
if above two memcpy are same why? if not, why???
Quest2
-------
one more thing how can i use macros in memcpy
like if i have
#define TRUE 1
then how can i copy TRUE into s1->name.
Quest3
---------
Moreover , if i copy two INTS as in
int a;
int b;
memcpy(a,b,sizeof(int));
memcpy(&a,&b,sizeof(int));
Though i have not tested above but as far as i remember both of the
above memcpy lines will compile and work..aint it koz of the reason
that memcpy upon receving arguments cast them......???(well i have no
idea :( )...
..Thanks a lot for your time ..please revert as soon as possible
Greetings and Happy New Year..
Waqas
-------------------------------------
"You laugh at me because i am different, i laugh at you because you are
all the same." - Kurt Cobaine
- Next message: Mark Gordon: "Re: using 8086 in C"
- Previous message: Old Wolf: "Re: problem abt printf on Turboc"
- Next in thread: Ben Pfaff: "Re: memcpy() Behaviour"
- Reply: Ben Pfaff: "Re: memcpy() Behaviour"
- Reply: Michael Mair: "Re: memcpy() Behaviour"
- Reply: Jonathan Bartlett: "Re: memcpy() Behaviour"
- Reply: Barry Schwarz: "Re: memcpy() Behaviour"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|