strcpy
Giorgos Keramidas
keramida at diogenis.ceid.upatras.gr
Wed Apr 26 02:48:31 EEST 2000
On Tue, Apr 25, 2000 at 01:52:23PM +0300, L.O.V.E. wrote:
> 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 ?
Sorry pou allaksa ligo to format tou programmatos, alla den mporousa
na to diabaso allios.. Des to monadiko sxolio pou prothesa kai afou
mpeis sto Zen kai dialogisteis ligo gia to pos kai giati to sugkekrimeno
lathos mporei na odhghsei se Segmentation Fault, tote tha eisai
pragmatika enlightened -- mexri to epomeno trivial error :)
--- program.c ---
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char source[] = "the source string";
int main (void)
{
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); /* never malloc'ed */
return 0;
}
--
linux-greek-users mailing list -- http://lists.hellug.gr
More information about the Linux-greek-users
mailing list