Re: strcpy HELP!!!!
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
>
> 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.
> * 0x40050be7*/
No wonder. You have to allocate memory for temp2 string before copying to it.
do temp2=malloc(strlen(temp1)+1); in between of two strcpy and everything's
gonna be OK.
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: