变量名如何存储在C中? [英] How is a variable name stored in C?

查看:100
本文介绍了变量名如何存储在C中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问变量C如何存储在C中?



更清楚地考虑以下代码:

  int main(){
int a = 1,b;
b = a + 2;
返回0;
}

例如,在这里存储器C中存储变量位置的名称。



例如,如果& a = 0x12A7 (假设)& b = 0x123B1 ,然后


I want to ask how C the variables are stored in C?

To be more clear consider the following code:

int main() {
    int a = 1, b;
    b = a + 2;
    return 0;
}

For example here in what memory C stores the names of variable places.

eg if &a=0x12A7(suppose) &b=0x123B1, then how and where does stores the variable names like in which memory name a is stored?

解决方案

C doesn't store name of the variables. Its the compiler that stores the names of variables in compiler's symbol table.
This data structure is created and maintained by compiler.
An example of a symbol table for the snippet

// Declare an external function
extern double bar(double x);

// Define a public function
double foo(int count)
{
    double  sum = 0.0;

    // Sum all the values bar(1) to bar(count)
    for (int i = 1;  i <= count;  i++)
        sum += bar((double) i);
    return sum;
}  

may contain at least the following symbol:

这篇关于变量名如何存储在C中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆