sprinaut

结构体数组赋值的赋值方法

typedef struct
{
    short        Id;
    char        Sstr[19];
} TestStr;  
     
第一种:
TestStr ls_TestStr[]
= {{0,"hello0"},{1,"hello11"}}; 第二种: TestStr ls_TestStr[2]; TestStr[0].Id = 0; TestStr[0].Sstr[19] = "hello"; TestStr[1].Id = 1; TestStr[1].Sstr[19] = "helloll"; 第三种: TestStr ls_TestStr[2] = {{0,"hello0"},};//此时只是对结构体数组ls_TestStr[0]进行了赋值

错误示例:
TestStr ls_TestStr[2] = {0,"hello0"};//这种赋值是错误的,并不能将所有的结构体数组都赋值

 

 

分类:

技术点:

相关文章:

  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
相关资源
相似解决方案