?
=?ISO-8859-15?Q?Jean=2DFran=E7ois?= Lemaire
Hello all,
I'm learning C and I still am struggling to understand some basic
concepts. For example, I read in the standard that with functions such
as strcpy, 'If copying takes place between objects that overlap, the
behavior is undefined.' But how can I be sure that they don't overlap?
For example, if I write this:
char string1[] = "overlap";
char string2[8];
strcpy(string2, string1);
string1 and string2 can't possibly overlap, can they? On the other hand,
I understand that if string2 was declared as:
char *string2;
I would be in trouble. But my main concern wouldn't be overlapping,
would it? That's where I'm confused.
I hope I'm making some sense.
JFL
I'm learning C and I still am struggling to understand some basic
concepts. For example, I read in the standard that with functions such
as strcpy, 'If copying takes place between objects that overlap, the
behavior is undefined.' But how can I be sure that they don't overlap?
For example, if I write this:
char string1[] = "overlap";
char string2[8];
strcpy(string2, string1);
string1 and string2 can't possibly overlap, can they? On the other hand,
I understand that if string2 was declared as:
char *string2;
I would be in trouble. But my main concern wouldn't be overlapping,
would it? That's where I'm confused.
I hope I'm making some sense.
JFL