首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Day 四: Arrays and Strings

2012-11-07 
Day 4: Arrays and StringsArray?fixed number of elements of the same type stored sequentially in mem

Day 4: Arrays and Strings

Array

?

fixed number of elements of the same type stored sequentially in memoryinitialization, or unexpected resultsarrays are passed by referencemultidimensional 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 suchchar hello[] = {'h','e','l','l','o','\0',}char hello = "hello"
#include <iostream>  #include <cstring>  using namespace std;  int main() {  char fragment1[] = "I'm a s";  char fragment2[] = "tring!";  char fragment3[20];  char finalString[20] = "";  strcpy(fragment3, fragment1);  strcat(finalString, fragment3);  strcat(finalString, fragment2);  cout << finalString;  return 0; }
?

?

热点排行