> 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 m
Lee Brinton:
> 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 al
-BEGIN PGP SIGNED MESSAGE-
You are correct. I was making specific assumptions based on the code
snippet
shown.
- -Original Message-
From: Lee Brinton [mailto:[EMAIL PROTECTED]
Sent: Friday, April 17, 1998 12:40 AM
To: debian-user Mailing List
Subject: RE: strcpy HELP!!!
Scott
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 l
Phil,
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.
Scott D. Killen
Scott Killen Software
http://www.skillsoft.com
-Original Message-
Fro
> #include
> #include
> #include
>
> void main(void)
> {
> char *temp1, *temp2;
> temp1 = malloc (10);
> strcpy (temp1, "high all");
> strcpy (temp2, temp1);
> printf("%s %s", temp1, temp2);
> }
> /* error --- program recieved signal SIGSEGV, Segmentation Fault.
> * 0x40050
This is your fault. You need to allocate memory for temp2.
void main(void)
{
char *temp1, *temp2;
temp1 = malloc (10);
insert `temp2 = malloc (10);' here.
strcpy (temp1, "high all");
strcpy (temp2, temp1);
printf("%s %s", temp1, temp2);
}
--
To UNSUBS
7 matches
Mail list logo