您的位置:首页 > 编程语言 > C语言/C++

C++基础学习4

2014-12-07 19:52 134 查看
#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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C++ 数组