strcpy

Giorgos Keramidas keramida at ceid.upatras.gr
Wed Apr 26 11:55:41 EEST 2000


On Wed, 26 Apr 2000, Stelios Xanthakis wrote:

> On Wed, 26 Apr 2000, Giorgos Keramidas wrote:
> 
> > 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 :)
> > 
> 
> Nomizo oti to programma tou pediou evgaze "Segmatation fault" I kati
> tetoio...

Nai, sosta nomizeis.
Pote den to amfisbhthsa auto.  Apla giati to kanei egrapsa :)

> Pistevo oti prepei o kathenas na pei tin ekdoxi tou pano sto thema.

Na po tin dikia mou?

Epeidi den egine arxikopoihsh tou pointer dest3 otan ton ekane dhlosi mesa
stin main(), autos eixe mia tuxaia timi.  Edeixne omws gia kali tou tuxi
kapou mesa stin stoiba.. kai gi' auto den tou petaei core stin grammi:

	strcpy(dest3, source);

alla tou petaei meta, otan prospathei na kanei free() kati, pou i
malloc() den to ekane allocate pote.  Tora, h erotisi einai bebaia, ti
einai pio shmantiko gia kapoion pou grafei kati tetoio:

  a) oti etsi ki allios kai free() na min kanei, exei gamisei to stack
     tou, kai anamfibola prepei na timorh8ei me kana duo core dumps, se
     asxetes stigmes?

  b) oti kanei free() kati pou etsi ki allios den egine allocate, ara
     mallon to core dump to exei toso sigouro pou, who cares?

  c) oti exo mia entuposi pos diabases to posting mou, alla dustuxos den
     katalabes pou to phgaina.

Pros apofugh tou (c) tis epomenes fores tha stelno kai disassembly tou
programmatos apo to gdb(1), me commented ta shmeia pou to .c source exei
kanei kati palabo.  H monh pagida stin olh ypothesi einai oti kapoia
stigmi, otan mazeutoun polla, ego bariemai na ta kano biblio, opote mallon
tha balo esena na ta stoixeio8ethseis :)))

As janampo sto Zen mou twra...

-- 
Giorgos "well, it seems i still know a bit of C" Keramidas


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




More information about the Linux-greek-users mailing list