Article View: es.comp.os.linux.programacion
Article #11783Re: Segmentation fault
From: X
Date: Fri, 05 Oct 2001 01:03
Date: Fri, 05 Oct 2001 01:03
34 lines
1583 bytes
1583 bytes
Santiago:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> El Thu, 4 Oct 2001 22:44:37 +0200, X escribi�:
>> struct kk
>> {
>> int popo;
>> char *name;
>> };
>>
>>
>> int main()
>> {
>> int n;
>> struct kk p;
>>
>> strcpy (p.name, "Jamoncito\n");
> p.name es un puntero.
> �Donde pides memoria para �l? No pides, luego no apunta
> a nada. p.name apunta a NULL y por tanto si escribes en
> �l, escribes en cualquier lugar de la memoria.
> Antes de ese strcpy necesitas un:
> p.name = malloc( 1000 );
> (por ejemplo).
Yo cre�a que strcpy alojaba memoria seg�n conveniencia... veo que estaba
equivocado.
Gracias.
Technical Details
Message-ID:
<8s0jp9.cp.ln@xxx.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!skynet.be!skynet.be!fu-berlin.de!uni-berlin.de!poolvisp2-mad-41.ipcom.comunitel.NET!not-for-mailReferences:
<lnhip9.bq.ln@xxx.com> <slrn9rpltn.l8.sromero@compiler.linux.es>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,b3c8decf211f42e0 X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2001-10-04 16:08:01 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!skynet.be!skynet.be!fu-berlin.de!uni-berlin.de!poolvisp2-mad-41.ipcom.comunitel.NET!not-for-mail From: X <x@xxx.com> Newsgroups: es.comp.os.linux.programacion Subject: Re: Segmentation fault Date: Fri, 5 Oct 2001 03:03:04 +0200 Lines: 34 Sender: <sobrino@xxx.com> Message-ID: <8s0jp9.cp.ln@xxx.com> References: <lnhip9.bq.ln@xxx.com> <slrn9rpltn.l8.sromero@compiler.linux.es> NNTP-Posting-Host: poolvisp2-mad-41.ipcom.comunitel.net (212.145.34.41) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 1002236878 19739510 212.145.34.41 (16 [105803]) X-Orig-Path: not-for-mail