小编Hád*_*dēs的帖子

是否可以将一个简单的代码块转换为结构体?

考虑以下代码:

#include <stdio.h>

int main()
{
  struct test {
    int i;
    int t;
  };

  struct test hello = (struct test) {
    .i = 0, 
    .t = 1
  };

  printf("%d, %d\n", hello.i, hello.t);

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

0, 1
Run Code Online (Sandbox Code Playgroud)

我的问题是这条线(struct test) {.i = 0, .t = 1 }在做什么?

它是否在输入一个代码块来输入struct test?甚至可能吗?

如果没有请告诉我它在做什么,谢谢.

c

3
推荐指数
1
解决办法
74
查看次数

标签 统计

c ×1