diff between memmove & memecpy

C

Christopher Benson-Manica

Joona I Palaste said:
I find it amazing how a C coder's competence is usually inversely
proportional to his/her usage of "U" and "ur" instead of "you" and
"your". Is it written somewhere in stone or is it just a rule of
thumb?

Possibly, although a friend of mine who I think codes significantly better C
than I do is fond of the "word" neways (that's "anyways" to English speakers).
 
A

Arthur J. O'Dwyer

friends,

Well, hold it for a second and go through the below given link.

[crazy-long link snipped; new link substituted]

} http://groups.google.com/groups?
} [email protected]


Please learn to do the following:

1) Trim quotes.
2) Bottom-post.
3) Trim "Google Groups" links to normal-people length.
4) Provide some sort of context for your remarks.
5) Use c.l.c for discussion of C, not Indian educational systems.


Thanks much.
-Arthur

(Your post does demonstrate how much the c.l.c regulars like
poking fun at clueless newbies, though. :)
 
K

Keith Thompson

Joona I Palaste said:
ROSY <[email protected]> scribbled the following:
PS. Please don't top-post.

http://www.faqs.org/docs/jargon/T/top-post.html This link is for
Debashis who may not be knowing what is top-post. In simpler terms,
top-post means posting answers above the questions.

[correct format...]
What is your name?
Debashis

[wrong format...]

Debashis
What is your name?

Except that new text should not be indented. Indentation, like "> ",
usually indicates that you're quoting something. (I usually use
4-space indentation when quoting sections of the standard, "> " when
quoting portions of a previous article.)

So the correct format is:
What is your name?
Debashis

Source code, of course, should be indented for legibility.
 
R

ROSY

U want 2 answer the levels of question,i think ur rubbish again,the questions
**** urself understand.if u take challenge then i'm going on further.But if u
dont give any response ur jugglery come 2 at an end.
Really ur fooing the bar.
 
J

Joona I Palaste

ROSY said:
U want 2 answer the levels of question,i think ur rubbish again,the questions
**** urself understand.if u take challenge then i'm going on further.But if u
dont give any response ur jugglery come 2 at an end.
Really ur fooing the bar.

Were you born this ignorant, or did you have to take a course? *PLONK*

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"'It can be easily shown that' means 'I saw a proof of this once (which I didn't
understand) which I can no longer remember'."
- A maths teacher
 
A

Arthur J. O'Dwyer

It is best 2 not spoke ur nose on this matter.
bye,


Gee, all those guys who plonked ROSY don't know
what they're missing. :)

It is probably not significant that a Google Groups
search on "author:ROSY" suggests the "Related Groups"
of comp.lang.c.* and soc.sexuality.spanking...

-Arthur,
now I'll be quiet
 
M

Michael Winter

on 26 Sept 03:
U want 2 answer the levels of question,i think ur rubbish again,the questions
**** urself understand.if u take challenge then i'm going on further.But if u
dont give any response ur jugglery come 2 at an end.
Really ur fooing the bar.

I appreciate that English is not your first language, but could you at
least attempt to make sense when posting - even if it means asking a
friend to translate for you.

Secondly, don't swear. Though most of the readers are adults, there's
no need.

Lastly, don't top-post.

Mike
 
T

Thomas Matthews

pete said:
Are you out of your MIND !?
OP's question is CLEARLY only about the string functions
which return type pointer to void, and which have side effects.

Anyway, the answer to the question is here:

http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/

FYI, the mem*() functions are not string functions. The string
functions are str*(), and work with NULL terminated character
arrays.

They do have side effects, which is their behavior.

Try this one:
#include <stdio.h>
#include <string.h>

#define BUFFER_LENGTH 64

int main(void)
{
const char * test_text = "How are you?\n\0\nMr. Potato?\n";
char result[BUFFER_LENGTH];
unsigned int i;

memset(result, '\0', 256);
/* string test */
strcpy(result, test_text);
for (i = 0; i < BUFFER_LENGTH; ++i)
{
putchar(result);
}

/* memcpy test */
memcpy(result, test_text, sizeof(*test_text));
for (i = 0; i < BUFFER_LENGTH; ++i)
{
putchar(result);
}
return 0;
}


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
T

Thomas Matthews

ROSY said:
U want 2 answer the levels of question,i think ur rubbish again,the questions
**** urself understand.if u take challenge then i'm going on further.But if u
dont give any response ur jugglery come 2 at an end.
Really ur fooing the bar.

ROSY,

Eye relly dont unnerstan Y U abreviat the short words but spel owt
da big wons.

I guess there isn't any convenient shorthand for "jugglery" or
"challenge". By the way (BTW), you (U) can shorten the word
"question" to "q's". If you can spend the extra time to type
out "your" instead of "ur" or "to" instead of "2", please don't
bother to type.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
K

Keith Thompson

Thomas Matthews said:
I guess there isn't any convenient shorthand for "jugglery" or
"challenge". By the way (BTW), you (U) can shorten the word
"question" to "q's". If you can spend the extra time to type
out "your" instead of "ur" or "to" instead of "2", please don't
bother to type.

I guess you can also abbreviate "can't" to "can". :cool:}
 
M

Mark McIntyre

On 25 Sep 2003 23:35:22 -0700, in comp.lang.c ,
It is best 2 not spoke ur nose on this matter.

don't be an idiot. This is not your private chatroom

and if you can't be polite, then you should go away.
 
P

pete

Thomas said:
FYI, the mem*() functions are not string functions. The string
functions are str*(), and work with NULL terminated character
arrays.

Who told you that ?


N869
7.21 String handling <string.h>
7.21.1 String function conventions
[#1] The header <string.h> declares one type and several
functions, and defines one macro useful for manipulating
arrays of character type and other objects treated as arrays
of character type. The type is size_t and the macro is
NULL (both described in 7.17). Various methods are used for
determining the lengths of the arrays, but in all cases a
char * or void * argument points to the initial (lowest
addressed) character of the array. If an array is accessed
beyond the end of an object, the behavior is undefined.

void* arguments have nothing to do with any functions
that start with str*.
They do have side effects, which is their behavior.

memcmp() has no side effects, which is part of the reason
that memcmp() does not belong in the same group
of string functions, as those which OP asked about.
Try this one:
#define BUFFER_LENGTH 64
char result[BUFFER_LENGTH];
memset(result, '\0', 256);

I don't think 256 is a good number to use there.
What's the point anyway ?
Your code has nothing to do with the fact that memcmp()
doesn't have side effects while memcpy(), memset(), and memmove()
do have side effects.
Your code has nothing to do with the fact that
memcpy(), memset(), memmove() and memcmp() are all string functions.
 
B

Barry Schwarz

pete said:
Are you out of your MIND !?
OP's question is CLEARLY only about the string functions
which return type pointer to void, and which have side effects.

Anyway, the answer to the question is here:

http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/

FYI, the mem*() functions are not string functions. The string
functions are str*(), and work with NULL terminated character
arrays.

They do have side effects, which is their behavior.

Try this one:
#include <stdio.h>
#include <string.h>

#define BUFFER_LENGTH 64

int main(void)
{
const char * test_text = "How are you?\n\0\nMr. Potato?\n";
char result[BUFFER_LENGTH];
unsigned int i;

memset(result, '\0', 256);

I haven't been following this thread in detail. Was it your intention
to invoke undefined behavior?
/* string test */
strcpy(result, test_text);
for (i = 0; i < BUFFER_LENGTH; ++i)
{
putchar(result);
}

/* memcpy test */
memcpy(result, test_text, sizeof(*test_text));


Was it your intention to copy only 1 byte? Since you did not
reinitialize result, do you expect the value in result to change?
for (i = 0; i < BUFFER_LENGTH; ++i)
{
putchar(result);
}
return 0;
}




<<Remove the del for email>>
 
R

R. Rajesh Jeba Anbiah

Arthur J. O'Dwyer said:
It is probably not significant that a Google Groups
search on "author:ROSY" suggests the "Related Groups"
of comp.lang.c.* and soc.sexuality.spanking...

In case, if you're not kidding, "author:name" is not the right
Google Groups search term. It should be rather "author:email" or just
"name"

---
"Never give in! Never give in! Never, Never, Never, Never – in
nothing great or small, large or petty – Never give in except to
convictions of honor and good sense." -- Sir Winston Churchill
http://guideme.itgo.com/atozofc/ - "A to Z of C" Project
Email: rrjanbiah-at-Y!com
 
R

ROSY

again spoking ur nose.

In case, if you're not kidding, "author:name" is not the right
Google Groups search term. It should be rather "author:email" or just
"name"

---
"Never give in! Never give in! Never, Never, Never, Never ? in
nothing great or small, large or petty ? Never give in except to
convictions of honor and good sense." -- Sir Winston Churchill
http://guideme.itgo.com/atozofc/ - "A to Z of C" Project
Email: rrjanbiah-at-Y!com
 
R

ROSY

r u harlot!!!dont be silly ,ur not at that level atleast.R u meet some plonker
except me????
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top