User Tools

Site Tools


c_-_c_streams:istrstream

C - C++ Streams - istrstream

#include <iostream>
#include <strstream>
using namespace std;
 
int main()
{
  char s[] = "10 Hello 0x75 42.73 OK";
 
  istrstream ins(s);
 
  int i;
  char str[80];
  float f;
 
  // reading: 10 Hello
  ins >> i;
  ins >> str;
  cout << i << " " << str << endl;
 
  // reading 0x75 42.73 OK
  ins >> hex >> i;
  ins >> f;
  ins >> str;
 
  cout << hex << i << " " << f << " " << str;
 
  return 0;
}
c_-_c_streams/istrstream.txt · Last modified: 2020/07/15 10:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki