vector::size_type与string::size_type

#include 
#include 
#include 
using namespace std;
int main()
{
   vector svec;    
   string str;
   cout << "Enter text:" << endl;
   while (cin>>str)
        svec.push_back(str);
   if (svec.size() == 0)
   {
        cout << "No string?!" << endl;
        return -1;
    }    
   cout << "Transformed elements from the vector:"<< endl;
    for (vector::size_type ix=0; ix!=svec.size()-1;++ix)
	//for (string::size_type ix=0; ix!=svec.size()-1;++ix)
	// vector改成string,编译、执行都正常
    {
		for (vector::size_type index = 0;index != svec[ix].size();++index)
		//for(string::size_type index = 0;index != svec[ix].size();++index)
			// vector改成string,编译、执行都正常
              if(islower(svec[ix][index])) 
				svec[ix][index]=toupper(svec[ix][index]);
				cout << svec[ix] << " ";    if ((ix+1) % 8 ==0) 
				cout << endl;
				cout << "Transformed elements from the vector:" << endl;
	 } 
	return 0;
}
#include 
#include 
#include 
#include 
using namespace std;

int main()
{
    cout<<"The sizeof string::size_type is "<::size_type is "<::size_type)<::size_type is "<::size_type).name()<



你可能感兴趣的:(C++)