#include using namespace std; #include /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char** argv) { //1.兩種字串: //(1)在 C 語言:以『字元陣列,字元指標』來做為字串型別, //(2)在 C++:用 『string 類別』為字串型別 //2.C語言:字元陣列與字元指標 //(1)宣告字元陣列 //格式:char name[length + 1]; //注意:字元陣列最後一個元素必須為空字元,其ASCII字元碼(0~255)為 0 ,代碼為 NUL。 //" char name[length + 1] = {'1','2','3',.....}; //未指派的空間會置入空字元 //" char name[length+1] = "12345"; //未指派的空間會置入空字元 //" char name[] = "12345"; //執行環境會自動在最末端串上空字元 char name1[] = "john"; char name2[5] = "john"; char name3[5] = {'j','o','h','n'}; char name4[5]; //output 字串 cout<<" name1 = "<