[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: strcpy HELP!!!



> Scott D. Killen writes:
> > You are copying the string to temp2 which has not been initialized and is a
> > NULL pointer.  You need to allocate memory of at least the same size as
> > temp1 to temp2 and
> > this will solve your problem.
> 
> When using C library string functions always allocate memory of at least the
> length of the string pointed to by temp1 plus 1 byte to hold the string
> termination character '\0'.
> 
> As in:
> 
> temp2 = (char*)malloc(strlen(temp1) + 1);

When doing strcpy(temp2,temp1) ???????????
How could it possibly do that?  It cannot change the value of temp2,
it is passed by value. Please read "man strcpy".

Good luck.

Alex Y.
-- 
   _ 
 _( )_
(     (o___           +-------------------------------------------+
 |      _ 7           |            Alexander Yukhimets            |
  \    (")            |       http://pages.nyu.edu/~aqy6633/      |
  /     \ \           +-------------------------------------------+


--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: