一、实验代码

#include <stdio.h>

void print(char s[]);

int main()
{
    print((char *)"abcdef");
    return 0;
}

void print(char s[])
{
    printf("%s\n",s);
}

二、实验结果

输出:abcdef

三、调试现象

字符串常量强制转换为字符指针

三、结论

  字符串常量强制转换为字符指针,是将字符串常量的地址作为这个指针值。至于这个常量的位置还不太确定。

 

相关文章:

  • 2021-11-07
  • 2021-08-14
  • 2021-06-11
  • 2022-01-03
  • 2022-12-23
  • 2021-08-08
  • 2019-08-21
  • 2021-06-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-28
  • 2022-01-17
  • 2022-12-23
  • 2021-11-06
相关资源
相似解决方案