// 此文版权属于作者本人,任何人、媒体或者网站转载、借用都必须征得作者本人同意
sstream_example.cpp
00001
//
$Id$
00002 /* *
00003 * @file sstream_example.cpp
00004 * @brief istringstream 和 ostringstream 使用例子
00005 *
00006 * 版权所有© 2004~2005
00007 * All rights reserved.
00008 *
00009 * @version $Revision$
00010 * @author 智勇
00011 * @date 2006年3月9日 21:12:11
00012 * */
00013 #include < iostream >
00014 #include < sstream >
00015
00016 using namespace std;
00017
00018 void sstream_example(){
00019
00020 cout << " ************************************************* " << endl;
00021 cout << " istringstream and ostringstream example: " << endl << endl;
00022
00023 istringstream istr( " SchemaSpy analyzes schema metadata. "
00024 " SchemaSpy also identifies several common schema anomalies. " );
00025
00026 ostringstream ostr;
00027
00028 cout << " Original string is : " << endl
00029 << istr.str() << endl;
00030 cout << " ------------------------------------------------- " << endl;
00031
00032 string str;
00033
00034 cout << " [ " ;
00035 while ( ! istr.eof()){
00036 istr >> str;
00037 if (istr)
00038 {
00039 cout << str << " " ;
00040 ostr << str << " " ;
00041 }
00042 };
00043 cout << " ] " ;
00044 cout << endl;
00045 cout << " ------------------------------------------------- " << endl;
00046 cout << " [ " ;
00047 cout << ostr.str();
00048 cout << " ] " ;
00049 cout << endl;
00050 }
00051
00052 int
00053 main( int argc, char * argv[])
00054 {
00055 sstream_example();
00056 return 0 ;
00057 }
00002 /* *
00003 * @file sstream_example.cpp
00004 * @brief istringstream 和 ostringstream 使用例子
00005 *
00006 * 版权所有© 2004~2005
00007 * All rights reserved.
00008 *
00009 * @version $Revision$
00010 * @author 智勇

00011 * @date 2006年3月9日 21:12:11
00012 * */
00013 #include < iostream >
00014 #include < sstream >
00015
00016 using namespace std;
00017
00018 void sstream_example(){
00019
00020 cout << " ************************************************* " << endl;
00021 cout << " istringstream and ostringstream example: " << endl << endl;
00022
00023 istringstream istr( " SchemaSpy analyzes schema metadata. "
00024 " SchemaSpy also identifies several common schema anomalies. " );
00025
00026 ostringstream ostr;
00027
00028 cout << " Original string is : " << endl
00029 << istr.str() << endl;
00030 cout << " ------------------------------------------------- " << endl;
00031
00032 string str;
00033
00034 cout << " [ " ;
00035 while ( ! istr.eof()){
00036 istr >> str;
00037 if (istr)
00038 {
00039 cout << str << " " ;
00040 ostr << str << " " ;
00041 }
00042 };
00043 cout << " ] " ;
00044 cout << endl;
00045 cout << " ------------------------------------------------- " << endl;
00046 cout << " [ " ;
00047 cout << ostr.str();
00048 cout << " ] " ;
00049 cout << endl;
00050 }
00051
00052 int
00053 main( int argc, char * argv[])
00054 {
00055 sstream_example();
00056 return 0 ;
00057 }