Loading...
In my previous book I have shown that how you can store details of single person using struct , but if you want to store multiple records then we can use mapping concept there .The code of this is given below
pragma solidity ^0.5.0;
contract mycontract{
struct details{
string name;
uint256 age;
string adhar;
}
mapping(uint256 => details) user;
uint256 number=0;
function setname(string calldata _name,string calldata _adhar,uint256 _age) external{
user[number].name = _name;
user[number].age = _age;
user[number].adhar = _adhar;
number++;
}
function getname(uint256 index) view external returns(string memory,string memory,uint256) {
return (user[index].name,user[index].adhar,user[index].age);
}
}