#include <IOSTREAM> #include <STRING> //数组的学习 int main(){ //整数数组 /* int array[5]; int i; for ( i=0;i<5;i++) { std::cout<<"Please input the value of array["<<i<<"]"<<std::endl; std::cin>>array[i]; } for ( i=0;i<5;i++) { std::cout<<i<<":"<<array[i]<<std::endl; }*/ //字符数组 // char buffer[80]={‘\0‘}; //std::cout<<"Please enter a String"<<std::endl; //std::cin>>buffer; //std::cout<<"Here is the buffer..."<<buffer<<std::endl; //数组拷贝 //char buffer[]="hello world"; //char buffer2[80]={‘\0‘}; //strcpy(buffer2,buffer); //std::cout<<buffer2<<std::endl; //字符串的创建 std::string str ("hello world"); std::cout<<str<<std::endl; std::string str2; str2=str; std::cout<<str2<<std::endl; str2="My name is LiLei"; std::cout<<str2<<std::endl; std::string result=str+str2; std::cout<<result<<std::endl; std::string str3; str3="My Friend is LiLei"; std::cout<<str3<<std::endl; return 0; }
时间: 2024-09-30 00:36:29