|
-
Dec 10th, 2002, 11:13 AM
#4
There is: stringstream:
Code:
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
int func(int i)
{
ostringstream oss;
oss << i;
string s = oss.str();
cout << s.c_str();
istringstream iss(s);
int j;
iss >> j;
cout << j;
s = "500";
iss.str(s);
iss >> j;
cout << j;
return j;
}
There it is. Header is <sstream>.
Input: basic_istringstream<typename character, typename traits = char_traits<character>, typename alloc = allocator<character> >
Output: basic_ostringstream<typename character, typename traits = char_traits<character>, typename alloc = allocator<character> >
Both: basic_stringstream<typename character, typename traits = char_traits<character>, typename alloc = allocator<character> >
char:
istringstream, ostringstream, stringstream
wchar_t: wistringstream, wostringstream, wstringstream
tchar:
typedef basic_istringstream<TCHAR> tistringstream;
typedef basic_ostringstream<TCHAR> tostringstream;
typedef basic_stringstream<TCHAR> tstringstream;
Derived from basic_istream/basic_ostream/basic_iostream, therefore the common << and >> overloads work.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|