//---------------------------------------------------------------------------
#include <iostream>
#include <cstring>
//---------------------------------------------------------------------------
char first[100];
char last[100];
char full_name[100];
int main(int argc, char* argv[])
{
std::strcpy(first, "Steve");
std::strcpy(last, "Oualline");
std::strcpy(full_name, first); // full = "Steve"
std::strcat(full_name, " "); // full = "Steve "
std::strcat(full_name, last); // full = "Steve Oualline"
std::cout << "The full name is " << full_name << '\n';
std::system("pause");
return 0;
}
//---------------------------------------------------------------------------
此程式的輸出是:
The full name is Steve Oualline
題目來源:C++風格與藝術 第二版 Steve Oualline 著 黃吉霈 編譯