结构体与临时变量增长顺序

#include <stdio.h>
#include <string.h>

struct Testscanf
{
    char input[20];
    char intput1[3];
};

int main() {
    char input[] = "John 25";
    char intput1[] = "12";

    printf("%p %p\n", (void*)input, (void*)intput1);
    struct Testscanf testscanf;
    strcpy(testscanf.input, "John 25");
    strcpy(testscanf.intput1, "12");
    printf("%p %p\n", (void*)testscanf.input, (void*)testscanf.intput1);

    return 0;
}

在windows下运行结果
000000b1b81ffa18 000000b1b81ffa15
000000b1b81ff9f0 000000b1b81ffa04

posted @ 2023-04-15 10:41  zhaogaojian  阅读(19)  评论(0编辑  收藏  举报