[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);

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Lee Brinton | 6xtippet@CyberJunkie.com
PGP public key @ http://www.icubed.com/~6xtippet/pgp-public-key.asc
-----------------------------------------------------------------------
The objective is not to die for your country,
but to make the enemy die for his country.
	-- Gen. George Patton
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


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


Reply to: