關于指針輸出字符串
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"
};