From: Bothe <Har...@pt...> - 2002-12-05 13:13:29
|
-------- Ursprüngliche Nachricht -------- Betreff: Re: [Sdcc-user] unsigned char to unsigned int warning Datum: Thu, 05 Dec 2002 14:09:27 +0100 Von: Bothe <Har...@pt...> An: Jesus Calvino-Fraga <Je...@ec...> Referenzen: <5.1...@ma...> <5.1...@ma...> Hello, again! > Still, for the last line you are copying pointers, not strings. > Therefore variable A will end up with part of the memory address where > "Hello" is allocated. You could very well have done: > > uchar * A; > . > . > A="Hello"; Thank you: I´ve learned something new again.... > uchar * A="Hello"; > uchar A[]="Hello";? Sorry, I´ve missed the astrisk. The second is equivalent. To be sure I´d put on my good ol´ Turbo C: #include <stdio.h> #include <conio.h> #include <stdio.h> #include <string.h> int main (void) { char *A = "Aello"; char B [] = "Bello"; char C[255]; char *D; /* C = "Cello"; ERROR: LValue required, but: */ strcpy (C, "Cello"); D = "Dello"; printf ("%s\n", A); printf ("%s\n", B); printf ("%s\n", C); printf ("%s\n", D); return (0); } Best regards Harald ---------------------------------------------------------------------- Dipl.-Ing. (FH) Harald Bothe eMail: Har...@pt... Tel.: (05 31) 5 92 - 21 12 Physikalisch - Technische Bundesanstalt Fax: (05 31) 5 92 - 21 05 Fachlabor 2.11, Wechselstromgrößen Bundesallee 100 Postfach 33 45 38116 Braunschweig 38023 Braunschweig Germany ---------------------------------------------------------------------- -- ---------------------------------------------------------------------- Dipl.-Ing. (FH) Harald Bothe eMail: Har...@pt... Tel.: (05 31) 5 92 - 21 12 Physikalisch - Technische Bundesanstalt Fax: (05 31) 5 92 - 21 05 Fachlabor 2.11, Wechselstromgrößen Bundesallee 100 Postfach 33 45 38116 Braunschweig 38023 Braunschweig Germany ---------------------------------------------------------------------- |