设为首页 加入收藏

TOP

Day 4: Arrays and Strings
2014-11-23 22:19:23 来源: 作者: 【 】 浏览:2
Tags:Day Arrays and Strings
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
#include
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;
}
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇堆排序-heapsort 下一篇Day 3: Functions

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: