Delphi Pascal & Builder C++ Character Problem
Grudge

In Pascal (Delphi), if I wanted to use control characters, I would use

// setup control characters
STX := Chr(2);
ETX := Chr(3);
ESC := Chr(27);
...

but how would I go and do it for c++ in builder, there is no Chr command (not in Builder C++ 6 anyways). Any ideas ?

X-G

char stx = 2;
char etx = 3;
char esc = 27;

Remember, chars are integral types. ::)

Grudge

ok, but if I use it in a ansistring, would the following work

AnsiString Output = stx + "whatevertext";

would the output be : '3whatever' ? or would it have the actual control character in the string (instead of 3) ?

X-G

I don't know what an AnsiString is, but the char will have the value 3. Not the literal '3', which is ascii value 51.

char a;

// These two are equivalent
a = '3';
a = 51;

Niunio

Try next:

char *ETX = {'3', 0};

Now, you can use strcat.

X-G

A string isn't the same as a char. Depends on what you want to use it for, of course.

Thread #276772. Printed from Allegro.cc