首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >推挽不起作用

推挽不起作用
EN

Ethereum用户
提问于 2022-08-27 19:31:10
回答 1查看 36关注 0票数 1

我正在创建一个待办事项列表,其限制是一个地址只能加到100条笔记。下面是代码片段

代码语言:javascript
运行
复制
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
contract todo
{
   struct llist
   {  
       uint no ;         // note no.
       string cont ;        // content
       address own ;         //  owner address
       bool iscom ;            // completed or not
       uint ttim ;              // time of creation
   }
    uint public i ; 
    mapping ( address => uint) public num ;        // for serial no. of note 
    mapping ( address => llist[100]) public num2 ;   // creating an array of 100 elements of struct type
    function real( string memory _contect) public
    {
        if (  num[msg.sender] > 99)

        i = 8 ;

        else
        {num2[msg.sender].push( num[msg.sender] , _contect,payable(msg.sender),false,block.timestamp);    // Line 1
                  num[msg.sender]++ ;
        }
     }
}

我使用将数据输入到位于该地址的结构数组中。不过,我还是在犯错误。

有人能告诉我我在这里做错了什么吗?

EN

回答 1

Ethereum用户

回答已采纳

发布于 2022-08-27 20:16:57

造成此错误的原因是,您试图在固定大小的数组100中使用push

push与动态大小数组一起使用。

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/134469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档