您当前的位置: 首页 > 
  • 0浏览

    0关注

    1477博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

FISCO BCOS Solidity 智能合约 返回数组

软件工程小施同学 发布时间:2020-09-27 17:32:17 ,浏览量:0

1. 定义函数时,返回值需要定义为数组,比如int[]

2. 函数中需要根据数据的多少初始化数组的大小

3. 为数组一一赋值

// 查询某个学生的某课成绩所有成绩
function select_all_scores(address studentId, string courseName) public view returns(int[]){
 
		TableFactory tf = TableFactory(0x1001);
		Table table = tf.openTable("stu_score");
 
		string memory stuIdStr = addressToString(studentId);
		Condition condition = table.newCondition();
		condition.EQ("student_id", stuIdStr);
		condition.EQ("course_name", courseName);
 
		Entries entries = table.select(stuIdStr, condition);
 
        // 初始化数组大小
        int[] memory user_scores_list = new int[](uint256(entries.size()));
        
        // 给数组赋值
		for(int i=0; i            
关注
打赏
1665320866
查看更多评论
0.0438s