0
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];
}

1 Answer 1

0

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];
 }
1
  • 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
    – u94
    Commented Nov 7, 2022 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.