简体   繁体   English

Arduino上的struct:function()'未命名类型'

[英]struct on Arduino: function() 'does not name a type'

I write a struct for variable and function, but is not work for me. 我为变量和函数编写了一个结构,但不适用于我。 I'm confused... 我糊涂了...

struct Array2 {
    int array[2] = {0, 1};
};

Array2 Digit2Arr2(int x) {
  Array2 v;
  if (x > 9) {
    int y;
    y=x/10; v.array[1]=x-(10*y); x=y;
    y=x/10; v.array[0]=x-(10*y); x=y;
  } else {
    v.array[0] = 0;
    v.array[1] = x;
  }
  return v;
}

'Array2' does not name a type “ Array2”未命名类型

Highly recommend you read up on how to create structs. 强烈建议您阅读有关如何创建结构的内容。

Heres somewhere you can start: 您可以从这里开始:

https://www.learncpp.com/cpp-tutorial/47-structs/ https://www.learncpp.com/cpp-tutorial/47-structs/

Your syntax is wrong in the creation of the struct. 您在创建结构时语法错误。

struct Array2 {
   int array[2] = {0, 1}; 
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM