摘要: 1 /* 2 * 将s,t两个字符串连接成单个字符串r 3 * */ 4 #include<iostream> 5 #include<stdlib.h> 6 #include<string.h> 7 using namespace std; 8 int main() { 9 char *s = "hello ";10 char *t = "world";11 char *r;12 13 r = (char *)malloc(strlen(s) + strlen(t) + 1);14 if(!r) {15 exit(1) 阅读全文
posted @ 2011-12-21 16:07 yanghuahui 阅读(214) 评论(0) 推荐(0)
摘要: *(a+i)即数组a中下标为i的元素的引用,这种写法被简记为a[i]。实际上a+i和i+a的含义一样,所以a[i]和[i]a也具有同样的意义。#include<iostream>using namespace std;int main() { int a[2] = {11,22}; int i = 1; cout<<a[i]<<endl; cout<<i[a]<<endl; return 0;} 经过实验,上面的代码,结果都是22。 阅读全文
posted @ 2011-12-21 15:30 yanghuahui 阅读(211) 评论(1) 推荐(1)