strcpy

L.O.V.E. mirror_92 at yahoo.com
Tue Apr 25 13:52:23 EEST 2000


Gia sas.
To programma pu akoloy8ei einai ena APLO programa pu perigrafei thn
strcpy synartisi.
Mou typwnei kanonika to output, OMWS mou dimioyrgei  panta core, opos
blepete sto telos :
Giati ayto ?


#include <stdlib.h>
#include <stdio.h>
#include <string.h>

char source[]="the source string";

int main()
{
 char dest1[80];
 char *dest2, *dest3;

printf("\n source: %s", source);

strcpy(dest1, source);
printf ("\n dest: %s", dest1);

dest2=(char *)malloc(strlen(source)+1);
strcpy(dest2, source);
printf("\n dest2: %s\n", dest2);

strcpy(dest3, source);
free(dest2);
free(dest3);

return 0;
}

output:
------------
source : the source string
dest1:  the source string
dest2 :  the source string
Segmatation fault(core dumped)

[natalia at localhost~]$


--
linux-greek-users mailing list -- http://lists.hellug.gr




More information about the Linux-greek-users mailing list