Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
Oblivion is currently offline  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


[Updated on: Sat, 17 April 2021 18:22]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: GLCtrl Linux dependency
Next Topic: Deprecated code
Goto Forum:
  


Current Time: Thu Mar 28 11:50:47 CET 2024

Total time taken to generate the page: 0.01949 seconds