C语言:结构体单独说明类型时应放在函数外,而变量可在使用它之前的函数外或内定义

#include <stdio.h>
main()
{
    struct stu {
        int a;
        int b;
    }; 
    struct stu ab;
    printf("%d",ab.a);
    getchar();
 }
 int abb(struct stu ma)
 {
     
 }

编译时提示:

 修改如下:

#include <stdio.h>
struct stu {
        int a;
        int b;
    }; 
main()
{

    struct stu ab;
    printf("%d",ab.a);
    getchar();
 }
 int abb(struct stu ma)
 {
     
 }

 

posted @ 2022-09-15 16:29  myrj  阅读(122)  评论(0编辑  收藏  举报