string类的io和char类比较 初始字符长度不一样

#include "stdafx.h"
#include "iostream"
#include "windows.h"
#include "string"
#include "cstring"

using namespace std;

int main(int argc, char* argv[])
{
	char ch1[21];
	string ch2;
	cout<<strlen(ch1)<<endl;
	cout<<ch2.size()<<endl;
	cout<<"Please input : ";
	cin>>ch1;
	cout<<"Please input : ";
	cin>>ch2;
	cout<<strlen(ch1)<<" "<<ch2.size()<<endl;
	system("pause");
	return 0;
}

你可能感兴趣的:(string类的io和char类比较 初始字符长度不一样)