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?

  • 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 Mar 3 '19 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 Mar 3 '19 at 2:57
  • @kriskoin why did you delete your answer? – Phillip Hamnett - EOS42 Mar 4 '19 at 12:31
  • @kriskoin you may answer your question and accept it, so others can find it as well. Thank you. – TeeAttack42 Mar 5 '19 at 11:22

Your Answer

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

Browse other questions tagged or ask your own question.