栈的实例[仅为自己验证某些理论,请绕道,hoho]

#include <stdio.h> 

typedef struct student
{
 int num1;
 double num2;
 float num3;
 char* name;
}student;

int fun1(int a1,int a2,student a3)
{
    
    printf("0x%08x\n",&a3);
    printf("0x%08x\n",&a2);
    printf("0x%08x\n",&a1);
    printf("----------------\n\n");
    int c = a1 + a2 ;
    
    int v1 =0,v2 = 3,v3 = 5;
     printf("0x%08x\n",&v1);
    printf("0x%08x\n",&v2);
    printf("0x%08x\n",&v3);
    
    printf("----------------\n\n");

    printf("0x%08x\n",&c);
    return c;
}

int main() 
{ 
    student s = {2,1000.3,3.0,'a'};
    int r = fun1(2,5,s);
    return 0; 
}



OutPut:

0xfff6b94c
0xfff6b960
0xfff6b964
----------------

0xfff6b97c
0xfff6b978
0xfff6b974
----------------

0xfff6b980


你可能感兴趣的:(C++,内存,栈)