1

I was looking at puts function in C++ (cstdio) and found that it returns non-zero value in case of success.

I tried searching on internet if there is any significance of that non-zero return value but could not find anything.

I have also tried multiple inputs to puts and tried to correlate that to the outputted value but no progress on that front as well.

Harshdeep
  • 5,614
  • 10
  • 37
  • 45
  • 4
    From [one of the most popular references](http://en.cppreference.com/w/cpp/io/c/puts): *Different implementations return different non-negative numbers: some return the last character written, some return the number of characters written (or INT_MAX if the string was longer than that), some simply return a non-negative constant. A typical cause of failure for std::puts is running out of space on the file system, when stdout is redirected to a file.* – chris May 21 '16 at 21:21
  • 1
    _On success, returns a non-negative value_ http://en.cppreference.com/w/cpp/io/c/puts No significance, the implementation can return any non-negative value that it wants to. – simon May 21 '16 at 21:21
  • I thought it just meant success, each individual value has no meaning in itself, just 0 means a fail. – Nick is tired May 21 '16 at 21:22
  • 3
    I think 0 is also success, -1 (EOF) means a fail. – Lassie May 21 '16 at 21:24

0 Answers0