g++ segmentation fault
Florian Lohoff
flo at rfc822.org
Wed Apr 26 15:15:08 CEST 2000
On Wed, Apr 26, 2000 at 03:13:52PM +0200, Dietmar Guhe wrote:
> On Wed, 26 Apr 2000, Florian Lohoff wrote:
>
> > Ich bin mal ein wenig ueberfragt - Interessant ist das dieses geht:
> >
> > void main(void ) {
> > char *a;
> > char b[5] = "text";
> > a=&b;
> ^^^^
>
> 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?
Hmmm - du hast recht - fuer mich wars jetzt so logischer - Naja - Der
compiler warned nur und machts dann richtig ...
(flo at paradigm)/tmp# gcc -Wall -O0 -g -o j j.c
j.c: In function `main':
j.c:5: warning: assignment from incompatible pointer type
Fuer mich war "b[5]" ein array of chars - Und "a" ein pointer auf (ein array of)
chars.
Dadurch muss eigentlich a=&b sein - Aber irgendwie ....
a=&b[0];
so waers dann richtig
Flo (Der auch kein C Experte ist)
--
Florian Lohoff flo at rfc822.org +49-subject-2-change
"Technology is a constant battle between manufacturers producing bigger and
more idiot-proof systems and nature producing bigger and better idiots."
-
Hinweise zur Benutzung dieser (und anderer Mailing-Listen) bitte beachten:
--> http://lug-owl.de/mailinglist_hints.html <--
More information about the Linux
mailing list