for(int i = 32; i < 128; ++i) { Cout() << "\t0x" << FormatIntHex(i, 2) << "\t0x" << FormatIntHex(i + 1, 2) << "\t0x" << FormatIntHex(i ^ (i + 1), 2) << "\n"; } // OR Cout() << "\t-------------\n"; for(int i = 32; i < 128; ++i) { Cout() << Format("\t0x%02x`\t0x%02x`\t0x%02x\n", i, i + 1, i ^ (i + 1));; }
Vector<String> arrAscii{ "" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ," " ," " ,"" ,"" ," " ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ," " }; //if you print in a text editor example cudatext, or more sophisticated editor you will see the contents below Vector<String> arrAscii{ "x01" ,"x02" ,"x03" ,"x04" ,"x05" ,"x06" ,"x07" ,"x08" ," " ," " ,"x0B" ,"x0C" ," " ,"x0E" ,"x0F" ,"x10" ,"x11" ,"x12" ,"x13" , "x14" ,"x15" ,"x16" ,"x17" ,"x18" ,"x19" ,"x1A" ,"x1B" ,"x1C" ,"x1D" ,"x1E" ,"x1F" ," " }; CONSOLE_APP_MAIN { String s; s << char(4); Cout()<< "show " << s << EOL; // not show! } //pascal procedure TForm2.SpeedButton1Click(Sender: TObject); var log:String; begin log := chr(4); showmessage( log ); // show "" ClipBoard.AsText := log ; // in text editor show "x04" end;
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(); }
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
CONSOLE_APP_MAIN { String s; s << (char)4; Cout()<< "show " << s << EOL; // not show! }
./your_program > your_file.txt
your_program.exe > your_file.txt
String Criptografia(String mStr, String mChave) { String s; int pos,posLetra; mChave=mChave; int TamanhoString = mStr.GetLength(); int TamanhoChave = mChave.GetLength(); for(int i = 0; i < TamanhoString; i++){ pos = (i % TamanhoChave); if( pos == 0) pos = TamanhoChave; int a = mStr[i]; int b = mChave[pos]; posLetra = a ^ b; if (posLetra == 0) posLetra = mStr[i]; s << char(posLetra); } return s; } CONSOLE_APP_MAIN { //first time you encripts String a=Criptografia("José da Silva","efg"); //second time you decrips String b=Criptografia(a,"efg"); Cout()<< b << EOL; }