1.如下实例:
#include <stdio.h>
int main(int argc ,char* argv[])
{
char* num[2]={"test","num"};
whicle(1)
{
printf("the num[0] is %s",num[0]);
}
}
运行程序输出:the num[0] is test,这时候有人疑问啦,不是应该输出地址值吗,num[]不是指针数组吗,里面存储的应该是地址值,为什么输出字符串啦,要输出字符串也应该这样表示:*num[0] 吗?。
原因:因为在输出的时候(%s)会自动的根据num[0]的地址值,找到相应的值然后输出来。