C++入門--3.0複合タイプ

1455 ワード

#include<iostream>
#include<cstring>//cstring   
 using namespace std;

 int main()
 {
	 //----------------------1.0     ----------------------------
	 //      1
	 //char dog[8]={'a','b','c','d','e','f','g','h'};
	 //char cat[8]={'a','b','c','d','e','f','g','\0'};

	 //// 2   
	 //char dog_B[8]="yanggan";
	 //char cat_B[8]="justtes";//      7 , 8     ‘\0’ 

	 //for(int i=0;i<8;i++)
	 //{
		//cout<<dog_B[i];
	 //}

 	 //----------------------2.0           ----------------------------
	 const int Size =15;
	 char name1[Size];
	 char name2[Size]="c++cowboy";

	 cout<<"hello,i am "<<name2<<"!,what is your name?"<<endl;
	 cin>>name1;

	 //sizeof()      , strlen()           。
	 cout<<"well,"<<name1<<",you name has "<<strlen(name1)<<" letter.
";// cout<<"And is stored in an array of "<<sizeof(name1)<<" bytes."<<endl;// name2[3]='\0';// '\0' , '\0' cout<<"Here are the first 3 characters of my name : "<<name2<<endl; }