我正在阅读一本关于C语言的书('掌握C'),并::在此处找到了有关范围解析运算符()的主题,请参阅第203页的Google Books .
但是当我运行以下代码示例(从本书中复制)时,C编译器给了我一个错误.我在互联网上搜索但我无法在C中找到任何对范围解析运算符的引用.
#include <stdio.h>
int a = 50;
int main(void)
{
int a =10;
printf("%d",a);
printf("%d\n", ::a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
所以,如果我想访问一个全局变量,那我怎么能从main()函数中做到这一点呢?
我应该在这里得到堆栈粉碎错误.我没有得到它的原因是什么?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct mun
{
int len;
char str[0];
};
int main(void)
{
//char mp[8];
struct mun *p=malloc(sizeof(struct mun)+2);
p->len=8;
strcpy(p->str,"munjalllfff");
//strcpy(mp,"munjalllfff");
printf("%s\n",p->str);
//printf("%s\n",mp);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果可能请解释或(主题名称或链接对我来说足够了.)