$ cat junk27.c
#include <stdio.h>
#include <string.h>
int main (void)
{
printf("The difference between memcpy and memmove is %ld\n",
(long int) memcpy - (long int) memmove);
return 0;
}
$ make junk27
cc -Wall -ansi -pedantic junk27.c -o junk27
$ ./junk27
The difference between memcpy and memmove is 48
$
So now we can put that behind us.
Mac
-- 21 5546
"Mac" <fo*@bar.net> wrote in message
news:pa******** *************** *****@bar.net.. . $ cat junk27.c #include <stdio.h> #include <string.h>
You don't need this header. int main (void) { printf("The difference between memcpy and memmove is %ld\n", (long int) memcpy - (long int) memmove);
Note: This is not portable. But if I wanted to do this,
I'd use 'unsigned long' or 'unsigned long long'.
6.3.2.3 Pointers
6 Any pointer type may be converted to an integer type.
Except as previously specified, the result is implementation-
defined. If the result cannot be represented in the integer type,
the behavior is undefined. The result need not be in the range
of values of any integer type.
AFAICT, 'previously specified' only refers to:
6.3.2.3
3 An integer constant expression with the value 0, or such
an expression cast to type void *, is called a null pointer
constant. If a null pointer constant is converted to a
pointer type, the resulting pointer, called a null pointer,
is guaranteed to compare unequal to a pointer to any object
or function.
return 0; }
-Mike
Mike Wahler wrote: "Mac" <fo*@bar.net> wrote in message news:pa******** *************** *****@bar.net.. .
$ cat junk27.c #include <stdio.h> #include <string.h> You don't need this header.
Are you so sure ? Seems to me that without it, memcpy and memmove are
undeclared identifiers...int main (void) { printf("The difference between memcpy and memmove is %ld\n", (long int) memcpy - (long int) memmove);
--
Bertrand Mollinier Toublet
Blog: http://www.bmt.dnsalias.org/blog
Mac wrote: $ cat junk27.c #include <stdio.h> #include <string.h>
int main (void) { printf("The difference between memcpy and memmove is %ld\n", (long int) memcpy - (long int) memmove); return 0; }
That's the first comp.lang.c article to make me GLOL for quite a while.
(Where has all the humour gone?)
--
Richard Heathfield : bi****@eton.pow ernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
"Bertrand Mollinier Toublet"
<be************ *************** **@enst-bretagne.fr> wrote in message
news:bl******** ****@ID-168218.news.uni-berlin.de... Mike Wahler wrote: "Mac" <fo*@bar.net> wrote in message news:pa******** *************** *****@bar.net.. .
$ cat junk27.c #include <stdio.h> #include <string.h>
You don't need this header. Are you so sure ? Seems to me that without it, memcpy and memmove are undeclared identifiers...
You are now authorized to beat me over the head
with an undeclared identifier until my behavior
becomes well-defined. :-)
-Mike
"Mac" <fo*@bar.net> wrote: $ cat junk27.c #include <stdio.h> #include <string.h>
int main (void) { printf("The difference between memcpy and memmove is %ld\n", (long int) memcpy - (long int) memmove); return 0; }
$ make junk27 cc -Wall -ansi -pedantic junk27.c -o junk27
$ ./junk27 The difference between memcpy and memmove is 48 $
*LOL*
Well, it's 16 on my implementation, which is one third of your result.
Does this mean the relation between memcpy and memmove is three times
closer on my system?
Irrwahn
--
Computer: a million morons working at the speed of light.
Richard Heathfield <do******@addre ss.co.uk.invali d> wrote: (Where has all the humour gone?)
The what?
--
Computer: a million morons working at the speed of light.
"Irrwahn Grausewitz" <ir************ *****@freenet.d e> wrote in message
news:o2******** *************** *********@4ax.c om... "Mac" <fo*@bar.net> wrote:
$ cat junk27.c #include <stdio.h> #include <string.h>
int main (void) { printf("The difference between memcpy and memmove is %ld\n", (long int) memcpy - (long int) memmove); return 0; }
$ make junk27 cc -Wall -ansi -pedantic junk27.c -o junk27
$ ./junk27 The difference between memcpy and memmove is 48 $ *LOL*
Well, it's 16 on my implementation, which is one third of your result. Does this mean the relation between memcpy and memmove is three times closer on my system?
If the relation is expressed in distance using
memory addresses, then it's 66.67% closer.
-Mike
On Sat, 27 Sep 2003, Mike Wahler wrote: "Irrwahn Grausewitz" <ir************ *****@freenet.d e> wrote in message news:o2******** *************** *********@4ax.c om... "Mac" <fo*@bar.net> wrote:
$ ./junk27 The difference between memcpy and memmove is 48
*LOL* Well, it's 16 on my implementation, which is one third of your result. Does this mean the relation between memcpy and memmove is three times closer on my system?
If the relation is expressed in distance using memory addresses, then it's 66.67% closer.
No, it's 66.67% *less far*. It's still three times *closer*,
using the traditional metric
closity = 1.0 / farthitude
:-)
-Arthur
"Mike Wahler" <mk******@mkwah ler.net> writes: printf("The difference between memcpy and memmove is %ld\n", (long int) memcpy - (long int) memmove);
Note: This is not portable. But if I wanted to do this, I'd use 'unsigned long' or 'unsigned long long'.
For what it's worth, C99 has intptr_t and uintptr_t in
<stdint.h>. But they are optional and don't apply to function
pointers anyway.
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: franky.backeljauw |
last post by:
Hello,
following my question on "std::copy versus pointer copy versus member
copy", I had some doubts on the function memcpy, as was used by tom_usenet
in his reply.
- Is this a c++ standard library function? That is, can I be sure that
every c++ standard library has this function? Or is there a c++
alternative to it?
|
by: bisforbenson |
last post by:
I'm trying to compile things with gcc 4. After running the following
command:
% gcc -O3 -g -Wall -Wno-unused -DLINUX -D_REENTRANT -o ../../obj/egi.o
-I../../include/ -I... -c egi.cpp
i get the following errors:
/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/cstring:79:
error: '::memcpy' has not been declared
|
by: Christopher Benson-Manica |
last post by:
(if this is a FAQ or in K&R2, I didn't find it)
What parameters (if any) may be 0 or NULL? IOW, which of the following
statements are guaranteed to produce well-defined behavior?
char src;
char dst;
memcpy( dst, src, 1 );
memcpy( NULL, src, 1 );
|
by: xdevel |
last post by:
Hi, anyone can make me an example where
memmove does not cause a memory overlapping and
where memcpy do it?
Thanks
|
by: somenath |
last post by:
Hi All,
I am trying to understand the behavior of the memcpy and memmove.
While doing so I wrote a program as mentioned bellow .
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE_OF_DST 3
int main(void)
| |
by: mthread |
last post by:
Hi,
I am copying data from one buffer(this data is a binary data not
string) to another buffer. Earlier when I used C, I used the memcpy
function call to copy the values. Is there any equivalent replacement
in C++ for this call.
|
by: gsi |
last post by:
Hi all,
memmove() is guranteed to work correctly if the objects overlap, I am not sure why this can't be done without any extra condition check in code for the memmove() implementation or why would memcpy() fail in this situation. Please advice.
Thanks in advance,
Gsi.
|
by: sam |
last post by:
(newbie)Technically what's the difference between memset() and
memcpy() functions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |