Array
fixed number of elements of the same type stored sequentially in memory
initialization, or unexpected results
arrays are passed by reference
multidimensional arrays are merely an abstraction for programmers, as all the elements in the array are sequential in memory
String
simply a character array and can be manipulated as such
char hello[] = {h,e,l,l,o,,}
char hello = "hello"
Cpp代碼
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char fragment1[] = "Im a s";
char fragment2[] = "tring!";
char fragment3[20];
char finalString[20] = "";
strcpy(fragment3, fragment1);
strcat(finalString, fragment3);
strcat(finalString, fragment2);
cout << finalString;
return 0;
}