0

I created a table with 5 rows/records. I tried to print the whole table content with the following code:

require_auth(_self);
accounts_table accounts(_self, _self.value);
for(auto itr = accounts.begin(); itr != accounts.end();++itr) {
   print( itr->parent_account);
   print("\n");
}

But only got one row.

When I call the command cleos -u get table ACCOUNT SCOPE TABLENAME, it shows all the 5 records.

Why does the code above only prints the first record?

4
  • I'm not sure why that code behaves that way, but can you try using C++11 syntax like for(auto & itr : accounts ) and tell us how it works out?
    – Jinu
    Commented Mar 3, 2019 at 1:36
  • 2
    thanks for your response, i just realize the scape caracter '\n' finalize the console output. for instance the code print("hi\n"); print ("how are you \n") only dsiplay "hi" in the console
    – kriskoin
    Commented Mar 3, 2019 at 2:57
  • @kriskoin why did you delete your answer? Commented Mar 4, 2019 at 12:31
  • @kriskoin you may answer your question and accept it, so others can find it as well. Thank you.
    – tmm
    Commented Mar 5, 2019 at 11:22

0

Your Answer

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

Browse other questions tagged or ask your own question.