我正在阅读一本旧书“ The C Programming Language”来学习C,并且目前正在尝试使用指针。
#include <stdio.h>
int
main (void)
{
// init string
char s[8] = "ZZZZZZZ";
// it goes: Z Z Z Z Z Z Z \0
long *p; // make pointer refering to the same adress as s
p = s; // but declared long for modifying 4 bytes at once
*p = 0x41414141; // and assign hexadecimal constant equal to 65 65 65 65
// expect output to be: AAAAZZZ
printf ("%s\n", s);
// but get …Run Code Online (Sandbox Code Playgroud) c ×1