contract YourContract {
struct student_marks
{
uint maths ;
uint science ;
}
mapping (address => student_marks) public record ;
function add_marks(uint _maths, uint _science) public
{
record[msg.sender] = student_marks(_maths , _science) ;
}
}
If msg.sender updates his marks the previous marks will be overwrite. Please help me how to keep record of marks of every msg.sender. No over-written. Drop a comment please if you think there's a solution. Hope so I elaborate my problem in a right way. Thankyou !
To save the key-value data of mapping without over-write the previous entries
Well, you need an array of records, not a single one.
mapping(address => StudentMarks[]) public records;Then for your
addMarksfunctionThen you just need to build your getMarks strategy, you can do it by index for example.