gpt4 book ai didi

c - 类型转换时指针的行为

转载 作者:行者123 更新时间:2023-12-01 06:15:08 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Why do these two pointer subtractions give different results?

char arr[] = "stackoverflow";
char *p1 = arr;
char *p2 = arr + 3;
printf("%d", (int*)p2 - (int*)p1);

它的答案是 0..你能解释为什么会这样吗?

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