[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppBuilderAddressToAnsi

(C++ Builder) Converting an address to a String

Note that when converting this address to either an integer or a String, this yields the same result.

  1. include <string>
  2. include <sstream>
std::string toString(const String& ansi) { const char * const myChar = ansi.c_str(); const std::string myString = myChar; return myString; } //--------------------------------------------------------------------------- String toAnsiString(const std::string& myString) { const char * myChar = myString.c_str(); const String myAnsi = myChar; return myAnsi; } //--------------------------------------------------------------------------- std::string addressToString(const void* const x) { std::ostringstream o; if (!(o << x)) return "ERROR"; return o.str(); } //--------------------------------------------------------------------------- int addressToInt(const void* const x) { const std::string myString = addressToString(x); return atoi(myString.c_str()); } //--------------------------------------------------------------------------- String addressToAnsi(const void* const x) { const std::string myString = addressToString(x); return toAnsiString(myString.c_str()); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *) { ShowMessage(addressToInt(this)); ShowMessage(addressToAnsi(this)); } //---------------------------------------------------------------------------


Other code snippets

'Address to AnsiString' links



last edited (December 20, 2006) by bilderbikkel, Number of views: 1767, Current Rev: 3 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.