Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (ANSI-Standard) » Convertieren vom Hex->int mit Stringstreams

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
15.10.2002, 20:20 Uhr
MarcDuerner



Hallo,
Kann mir jemand sagen wie ich einen stringstream benutze um eine Hexadecimalzahl in einen normalen Integerwert umzuwandeln?

Danke,
Marc
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
15.10.2002, 20:46 Uhr
void*
Generic Pointer
(Operator)


Hallo!

Etwa so (geht wahrscheinlich eleganter):

C++:
#include <string>
#include <iostream>
#include <sstream>
#include <iomanip>

int main(void)
{
  std::string hex("0xff");
  std::stringstream ss;
  ss.unsetf(std::ios_base::dec);
  ss.setf(std::ios_base::hex );
  ss << hex;
  int x;
  ss >> x;
  std::cout << x << "\n";

  return(0);
}



Gruß
void*
--
Gruß
void*
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ C / C++ (ANSI-Standard) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: