指针入门

include<stdio.h>

int main()
{
int arr[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
printf("%d\n",&arr[9] - &arr[0]);//中间数组的个数
return 0;
}
strlen求字符串的长度'/0'之前的字符
int my_strlen(char* str)
{
char* start = str;
char* end = str;
while (end != '\0')
{
end++;
}
return end - start;
}
int main()
{
char arr[] = "good";
int len = my_strlen(arr);
printf("%d\n", len);
return 0;
}
二级指针
int main()
{
int a = 10;
int
pa = &a;
int** ppa = &pa;
**ppa = 10 + 10;
printf("%d\n", *ppa);
printf("%d\n", a);
}
int main()
{
int a = 5,b = 20,c = 10;
int
arr[3] = { &a, &b, &c };
for (int i = 0; i<3; i++)
{
printf("%d, ", arr[i]);
}

return 0;

}

posted @ 2024-01-20 21:27  累die  阅读(4)  评论(0编辑  收藏  举报