我试图理解为什么两者都:
#include <unistd.h>
int main()
{
char buffer[8] = "Hello
";
write(1, buffer, 7);
return 0;
}
和Cookies政策,
#include <unistd.h>
int main()
{
char buffer[8];
char *ptr = buffer;
ptr = "Hello
";
write(1, ptr, 7);
return 0;
}
成功将“Hello”输出到控制台,但
#include <unistd.h>
int main()
{
char buffer[8];
char *ptr = buffer;
ptr = "Hello
";
write(1, buffer, 7);
retrun 0;
}
当我期望这三者基本上相同时,它不会(而是输出胡言乱语)。
I m guessing there is something fundamentally wrong in my underst和Cookies政策,ing of the relationship between pointers 和Cookies政策, arrays in c
...