1 Star 0 Fork 0

heitufei/stupid-c

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ex15.c 857 Bytes
一键复制 编辑 原始数据 按行查看 历史
heitufei 提交于 2016-12-22 20:42 . ex15 16
#include <stdio.h>
int main(int argc, char *argv[])
{
int ages[] = {23, 43, 12, 89, 2};
char *names[] = {
"Alan", "Frank",
"Mary", "John", "Lisa"};
//printf("test for first e of array : %d\n", *ages);
int count = sizeof(ages) / sizeof(int);
int i = 0;
for (i = 0; i < count; i++) {
printf("%s has %d years alive.\n", names[i], ages[i]);
}
printf("------\n");
int* cur_age = ages;
char** cur_name = names;
for (i = 0; i < count; i++) {
printf("%s has %d years alive.\n", *(cur_name+i), *(cur_age));
}
printf("-----------");
for (i = 0; i < count; i++) {
printf("%s has %d years alive.\n", cur_name[i], cur_age[i]);
}
printf("--------------------\n");
for (cur_name = names, cur_age = ages; (cur_age - ages) < count; cur_age++, cur_name++ ) {
printf("%s has %d years alive.\n", *cur_name, *cur_age);
}
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/heitufei/stupid-c.git
git@gitee.com:heitufei/stupid-c.git
heitufei
stupid-c
stupid-c
master

搜索帮助