Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7984031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:08:24+00:00 2026-06-04T11:08:24+00:00

When a stdio stream encounters an error (but not EOF), the stream’s error indicator

  • 0

When a stdio stream encounters an error (but not EOF), the stream’s error indicator will be set so that ferror() will return nonzero. I have always assumed that more information is available in errno. But how do I know this?

Documentation for some functions [e.g. man fopen under Linux] says that errno will also be set. However man fgets doesn’t mention errno at all. The glibc info pages are reassuring:

In addition to setting the error indicator associated with the
stream, the functions that operate on streams also set `errno’ in the
same way as the corresponding low-level functions that operate on file
descriptors.

But I have no idea how strong this guarantee is. Is it required by the C standard? What happens in Visual C/C++?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:08:26+00:00Added an answer on June 4, 2026 at 11:08 am

    The C Standard itself does not require much use of errno WRT to stdio functions; it specifies ferror() but says of it only that

    7.13.10.3 The ferror function The ferror function tests the error indicator for the stream pointed to by stream. The ferror function returns nonzero if and only if the error indicator is set for stream.

    from the C99 Draft: http://www.vmunix.com/~gabor/c/draft.html. Any actual error codes used are, for the most part, implementation defined.

    However, the GNU C library on linux also conforms to POSIX specifications:

    http://pubs.opengroup.org/onlinepubs/9699919799/toc.htm

    Which are much more well defined in this context. For example, if you look at the page for fopen:

    http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html

    You’ll see a lot of detailed information, including specific errno codes, under Errors.

    Again, the GNU C library used on virtually all normal linux systems is POSIX compliant, so you can count on that information ;). Those (online) POSIX man pages are also generally more detailed than the standard linux system man pages (read both).

    WRT to file operations on other (non-POSIX) platforms, they will have their own implementations. Unfortunately, stuff like that is not transparently portable in standard C. C++ streams do have more standardized error handling, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got some problems with EOF and stdio in a communication pipeline between a
I have following simple program: import std.stdio; int main(string[] argv) { writeln(Hello, world!); return
I am trying to use ASIO (Audio Stream Input/Output). I downloaded SDK, but because
I'm trying to write generic code that can lex any stream of characters (
#include <stdio.h> #include<stdio.h> #include <ctype.h> /** * Display the contents of a stream as
I am getting an error related to err_sys() in this code: #include <stdio.h> #include
My view is that a C implementation cannot satisfy the specification of certain stdio
Apparently POSIX states that Either a file descriptor or a stream is called a
I have a program that prints UTF-8 string to the console: #include <stdio.h> int
I'm writing a program that I want to distribute to other people, but it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.