c_-_c_string_streams:istrstream
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
c_-_c_string_streams:istrstream [2017/10/12 11:18] – peter | c_-_c_string_streams:istrstream [2017/10/12 13:14] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== C - C++ String Streams - istrstream ====== | ||
- | |||
- | <code cpp> | ||
- | #include < | ||
- | #include < | ||
- | 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.1507807117.txt.gz · Last modified: 2020/07/15 09:30 (external edit)