M
mdh
I have a question about the library function strcpy.
In K&R on page 109, strcpy is used to copy a line ( line[] ) to a
pointer (char *), which is first allocated space by K&Rs "alloc"
function.
In a few pages prior to this, the example that K&R showed used this
definition for it's version of strcpy
void strcpy( char *s, char *t){
while ( *s++ = *t++);
}
Could someone help me understand the library function, which,
according to the appendix, returns the target string.
So, in this case, what is passed to the library is an array-the
original string and a pointer to the target string? What happens if
the target pointer has not been allocated space? And, is this
acceptable ie to pass a pointer instead of an actual char array for
the target string?
tks
In K&R on page 109, strcpy is used to copy a line ( line[] ) to a
pointer (char *), which is first allocated space by K&Rs "alloc"
function.
In a few pages prior to this, the example that K&R showed used this
definition for it's version of strcpy
void strcpy( char *s, char *t){
while ( *s++ = *t++);
}
Could someone help me understand the library function, which,
according to the appendix, returns the target string.
So, in this case, what is passed to the library is an array-the
original string and a pointer to the target string? What happens if
the target pointer has not been allocated space? And, is this
acceptable ie to pass a pointer instead of an actual char array for
the target string?
tks