> 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
-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Phil
Sent: Wednesday, April 15, 1998 9:01 PM
To: debian-user@lists.debian.org
Subject: strcpy HELP
I'm using libc6 2.0.7pre1-4 and strcpy gives me a segmentation
error!
I've attached my C test program for inspection(source
> #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
I'm using libc6 2.0.7pre1-4 and strcpy gives me a segmentation
error!
I've attached my C test program for inspection(source only).
I only do a few things. malloc memory for a variable(forgot a
corresponding free)
copy a string in this varible, copy this string to another
string, print both
on the
8 matches
Mail list logo