gpt4 book ai didi

arrays - 为什么 C 中的指针可以在不取消引用的情况下打印其内容?

转载 作者:行者123 更新时间:2023-12-05 08:47:16 25 4
gpt4 key购买 nike

<分区>

我创建了一个程序,其中我注意到两件事

  1. 我使用指针的地址来打印整个单词并且它有效但是当我将 s 替换为*s 它没有工作(为什么会这样?)(我在 printf 中使用地址而不是 *s 内容)
  2. 当我使用指向指针的指针来打印字符时,我无法打印任何东西(我的意思是当我用 %c 替换了 %s

我的代码:

#include<stdio.h>


int main ()
{
char str[10]="PinkFloyd";
char *s;
char **s1;

s=&str[0];

s1=&s;

printf("the word is using pointer to pointer %s",*s1); //why if I used %c does not print the first character
printf("\n");
printf("the word is using s pointer %s",s); // why if I had replaced with *s does not print anything



return 0;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com