Article View: es.comp.os.linux.programacion
Article #11780Re: Segmentation fault
From: Santiago Romero
Date: Thu, 04 Oct 2001 21:42
Date: Thu, 04 Oct 2001 21:42
44 lines
2065 bytes
2065 bytes
-----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).
- --
"Oferta! De serie con nuestra nueva versi�n de EMACS, 1 tecla
de CONTROL y otra de ALT de repuesto."
_O)
NoP / Compiler | compiler@escomposlinux.org - ICQ #98602813 /\\
Linux Debian 2.2 | http://escomposlinux.org/sromero - #74.821 \_V
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAju817kACgkQx0J/i4MrH+d5RgCcDgtHh7q8TFTC4zixfNK8t/CL
tS4AoKi7krHj4jWqdFfPLlMjrjzxh3Us
=OdNF
-----END PGP SIGNATURE-----
Technical Details
Message-ID:
<slrn9rpltn.l8.sromero@compiler.linux.es>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!va1-ras-3-u-0103.du.onolab.COM!not-for-mailReferences:
<lnhip9.bq.ln@xxx.com>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 14:52:58 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!va1-ras-3-u-0103.du.onolab.COM!not-for-mail From: Santiago Romero <sromero@escomposlinux.org> Newsgroups: es.comp.os.linux.programacion Subject: Re: Segmentation fault Date: Thu, 4 Oct 2001 23:42:17 +0200 Lines: 44 Message-ID: <slrn9rpltn.l8.sromero@compiler.linux.es> References: <lnhip9.bq.ln@xxx.com> Reply-To: compiler@escomposlinux.org NNTP-Posting-Host: va1-ras-3-u-0103.du.onolab.com (62.42.60.104) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 1002232377 19217930 62.42.60.104 (16 [39726]) X-Orig-Path: 127.0.0.1!nobody User-Agent: slrn/0.9.7.2 (Linux)