Prosumer[] public ProsumeArray;
struct Prosumer{
uint ProsumerID;
uint Pros_power;
uint per_unit_rate;
}
function setPros(uint ProsumerID, uint Pros_power,uint per_unit_rate)public {
Prosumer memory newProsumer=Prosumer({
ProsumerID: ProsumerID,
Pros_power: Pros_power,
per_unit_rate: per_unit_rate
});
ProsumeArray.push(newProsumer);
}
function ChoosePro(uint n) public view returns(uint ){
return ProsumeArray[n];
}
Add a comment
|
1 Answer
What are you trying to return?
it seems you are trying to return the struct Prosumer in that case your return type should be Prosumer you can see in the following code:
function ChoosePro(uint n) public view returns(Prosumer memory){
return ProsumeArray[n];
}
-
I want to access one element of the array. So that I can perform addition and subtraction of the element with reference to other uint values– u94Commented Nov 7, 2022 at 10:06