Autor Beitrag
michaelarban
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Do 12.08.10 14:48 
Hallo,

wenn ich folgendes definiere:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var
 test : Pchar

begin
test := PChar('   1    ');

dann wird im Debugfenster auch '   1   ' angezeigt.


Wenn ich aber

test := PChar('1'); schreibe sehe ich im Debuggenster nur ''



Weiss jemand warum ich kein PChar der länge 1 zuweisen kann?

danke
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Do 12.08.10 15:14 
Wir die Variable Test nach der Zuweisung nochmal benutzt?

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)
Gammatester
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 328
Erhaltene Danke: 101



BeitragVerfasst: Do 12.08.10 15:25 
Das Literal ' 1 ' ist wirklich ein string oder pchar, das Literal '1' ist ein char. Bei Pchar('1') wird der Wert $31 als Zeiger interpretiert. Pchar(1) ist zeigt auch nichts sinnvolles. IntToHex(integer(PChar('1')),8) zeigt '00000031', IntToHex(integer(PChar('   1   ')),8) hingegen eine sinnvolle Addresse.
michaelarban Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Do 12.08.10 15:33 
hi,

ja ich benutze die Variable später;


bye
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 12.08.10 19:21 
'1' ist ein Char, ' 1 ' ein String. Wenn du '1' als string willst, musst du string('1') schreiben, sprich PChar(string('1'))

Für diesen Beitrag haben gedankt: BenBE, Hidden
michaelarban Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Do 12.08.10 20:22 
ok,

danke, werde ich morgen ausprobieren.

tschüss