我正在创建一个待办事项列表,其限制是一个地址只能加到100条笔记。下面是代码片段
//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]++ ;
}
}
}
我使用将数据输入到位于该地址的结构数组中。不过,我还是在犯错误。
有人能告诉我我在这里做错了什么吗?
发布于 2022-08-27 20:16:57
造成此错误的原因是,您试图在固定大小的数组100中使用push
push与动态大小数组一起使用。
https://ethereum.stackexchange.com/questions/134469
复制相似问题