g++ segmentation fault

Dietmar Guhe dguhe at Mathematik.Uni-Bielefeld.DE
Wed Apr 26 16:15:18 CEST 2000


On Wed, 26 Apr 2000, Florian Lohoff wrote:

> Date: Wed, 26 Apr 2000 15:28:39 +0200
> From: Florian Lohoff <flo at rfc822.org>
> To: Dietmar Guhe <dguhe at Mathematik.Uni-Bielefeld.DE>
> Cc: "linux at lug-owl.de" <linux at lug-owl.de>
> Subject: Re: g++ segmentation fault
> 
> On Wed, Apr 26, 2000 at 03:31:56PM +0200, Dietmar Guhe wrote:
> > On Wed, 26 Apr 2000, Peter Ohlerich wrote:
> > 
> > > Dietmar Guhe wrote:
> > > > ...
> > > > Verstehe ich nicht. b ist doch schon ein Pointer auf Character. Warum
> > > > sollte man von diesem Pointer wieder die Addresse nehmen (&b). Bei mir
> > > > laeuft das ganze durch, wenn ich a=b einsetze. Oder hab ich das Problem
> > > > nicht verstanden?
> > > > 
> > > > Dietmar
> > > 
> > > Hallo!
> > > 
> > > Wenn wir den armen Frager noch weiter verwirren wollen, dann ist es
> > > jetzt Zeit dringend die Sache mit new/delete bzw. malloc/free auf den
> > > Tisch zu packen ;-)
> > 
> > Also: 
> > 
> > char *a;
> > a[2]='2'; 
> 
> Moep - Falsches beispiel
> 

Mist, keine Punkte in dieser Runde.

Abgetippt aus C The Complete Reference (Seite 128):
 
char *p ="hello world";

As you can see, the pointer p is not an array. the reason this sort of
initialization works is because of the way the compiler operates. All C
compilers create what is called a string table, which is used internally
by the compiler to store the string constants used by the program.
Therfore, the preceding declaration statement places the addres of "hello
world", as stored in the string table, into the pointer p. Throughout a
program, p can be used like any other string. ...

Aber eben leider nicht, als ein Speicherbereich, der "frei" verfuegbar
ist. 
So verstehe ich das zumindest.

Dietmar

-- 
Windows User vs. Linux User: 
Die einen befolgen (legen Sie die .. in Laufwerk .. ein)
und die anderen geben (mount ..) Anweisungen.
http://www.mathematik.uni-bielefeld.de/~dguhe/
------------------------------------------------------






-
Hinweise zur Benutzung dieser (und anderer Mailing-Listen) bitte beachten:
--> http://lug-owl.de/mailinglist_hints.html <--



More information about the Linux mailing list