struct結構體成員變量賦值


struct成員賦值方法

  • 常見的方法就不說明了!
  • 下面介紹三種方式

1.第一種:

#include <stdio.h>

struct test
{
    int a;
    int b;
};

int main(int argc, char** argv)
{
    struct test node = {
                   node.a= 1,
                   node.b= 2
                };
    /**
     struct test node = {
                   .a= 1,
                   .b= 2
                };
    */
    printf("%d", node.a);
    return 0;
}


  1. 第二種:
    struct test node = {
                   a: 1,
                   b: 2
                };

  1. 第三種:
  struct test node = {
                   1,
                   2
                };


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM