void hi(){
            string strNum;
            float currNum = std::stof(strNum);//  


MacBook-Plou:testkeys treaser$ cleos push action fy hi '[]' -p testhero@active
Error 3070002: Runtime Error Processing WASM
Error Details:
wabt execution failure (out of bounds memory access)
pending console output: 
  • Please add a decent description about what you are trying to do.
    – TeeAttack42
    Nov 16 '18 at 16:27
  • he's obviously trying to parse a string containing a number into a float
    – ekkis
    Feb 3 '19 at 1:28
  • @Lou, I have this same issue. did you solve it?
    – ekkis
    Feb 3 '19 at 1:28
  • this seems important enough for me to report it as a bug on github: github.com/EOSIO/eosio.cdt/issues/404
    – ekkis
    Feb 3 '19 at 1:33

I couldn't make that happen either but I did make this work:

std::string s("limit: 686.97");
float limit = atoi(s.c_str());
printf("limit [%f]\n", limit);

* Edit I *

of course, that gets us to integer. sadly the atof is not available, so I think counting the number of digits in the string, removing the dot, converting to an integer and then dividing by the number of digits would give the correct value. bloody mess

float _stof(std::string s)
    std::size_t i = s.find(".");
    int digits = s.length() - i - 1;
    s.erase(i, 1);
    return atoi(s.c_str()) / pow(10, digits);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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