关于指针输出字符串
const char *p = "something is pointing at me.";
puts(p);
将字符串看作指针
#include<stdio.h>
int main()
{
printf("%s %p %c\n","we","are",*"space farers");
}
//输出
we 0x100000f61 s
使用指针表示法创建字符串
const char *p = "something is pointing at me .";
//下面的声明和上面几乎相同
const char ar1[] = "something is pointing at me .";
数组和指针的区别、数组名heart 是常量,指针名head 是变量(壳进行递增操作)
char heart [] ="i love you !";
const char *head = "i love you !";
//使其等价
head=heart;
指向字符串的指针数组和char类型数组的数组
const char *myarray[LIM]={
"adding number swiftly",
"understanding ins"
};
char youarray[LIM][SLEN]={
"walking in a straight line",
"sleeping letters"
};
网友评论