User Tools

Site Tools


c_-_c_string_streams:istrstream

This is an old revision of the document!


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_string_streams/istrstream.1507813776.txt.gz ยท Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki