Home » Community » Coffee corner » operation with ascii table character (Pascal x C++/U++)
Re: operation with ascii table character (Pascal x C++/U++) [message #56816 is a reply to message #56812] |
Sat, 17 April 2021 18:20 |
Oblivion
Messages: 1091 Registered: August 2007
|
Senior Contributor |
|
|
Hello BetoValle,
I see. AFAIK there is no such formatter in U++ (it is too specific, IMO).
But it is easy to create one, using operator overloading, for example.
String& operator*(String& s, int c)
{
if(c >= 0x20 && c <= 0x7E)
s.Cat(c);
else
s << "0x" << FormatIntHex(c, c < 256 ? 2 : 4);
return s;
}
String& operator*(String& s, const String& q)
{
for(int c : q) s * c;
return s;
}
CONSOLE_APP_MAIN
{
Vector<String> v;
for(int i = 0; i < 256; i++) v.Add() * i;
Cout() << v.ToString();
}
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Sat, 17 April 2021 18:22] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu Mar 28 11:50:47 CET 2024
Total time taken to generate the page: 0.01949 seconds
|