Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • \$\begingroup\$ Based on my experience, the return value of puts() is machine dependent. It's 10 on mine for instance. Also, here's a tip: you can usually compress two loops into one if you conditionally increment the counter in the external loop. My solution demonstrates how it can be done. \$\endgroup\$ Commented Oct 20, 2015 at 12:28
  • \$\begingroup\$ @xsot Yes, puts() return code is only guaranteed to be +ve for success. However my testing with glibc seems show that the return value is number of bytes written. As for the loop consolidation - yes, I'm aware of that technique and have tried that here, so far with no shortening in this case. \$\endgroup\$ Commented Oct 20, 2015 at 17:11