(注:本实验在x86架构下gcc编译器下完成)
我们先做一个有关static变量的实验
#include <stdio.h>
static char txbuf1[1021] ={0};
static char txbuf2[20];
int main()
{
static char txbuf3[30] ={0};
static char txbuf4[40];
static char txbuf5[40];
txbuf1[0] = 1;
txbuf2[0] = 2;
txbuf3[0] = 3;
txbuf4[0] = 4;
txbuf5[0] = 4;
printf("%s enter--%d%d%d%d%d\n", __func__,txbuf1[0],txbuf2[0],txbuf3[0],txbuf4[0],txbuf5[0]);
return 0;
}
Disassembly of section .bss:
0000000000004020 <completed.0>:
...
0000000000004040 <txbuf1>:
...
0000000000004440 <txbuf2>:
...
0000000000004460 <txbuf3.3>:
...
0000000000004480 <txbuf4.2>:
...
00000000000044c0 <txbuf5.1>:
...
我们先做一个有关全局变量的实验
#include <stdio.h>
char txbuf1[1021] ={0};
char txbuf2[20];
int main()
{
char txbuf3[30] ={0};
char txbuf4[40];
char txbuf5[40];
txbuf1[0] = 1;
txbuf2[0] = 2;
txbuf3[0] = 3;
txbuf4[0] = 4;
txbuf5[0] = 4;
printf("%s enter--%d%d%d%d%d\n", __func__,txbuf1[0],txbuf2[0],txbuf3[0],txbuf4[0],txbuf5[0]);
return 0;
}
Disassembly of section .bss:
0000000000004020 <completed.0>:
...
0000000000004040 <txbuf1>:
...
0000000000004440 <txbuf2>:
...
总结: