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 7952987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:01:43+00:00 2026-06-04T03:01:43+00:00

There is this thing that gives me headaches in C programming when I deal

  • 0

There is this thing that gives me headaches in C programming when I deal with reading from files.

I do not understand the difference between these 2 methods:

FILE *fd;
fd=fopen(name,"r");  // "r" for reading from file, "w" for writing to file
                      //"a" to edit the file

fd returns NULL if the file can’t be open, right?

The second method that i use is:

int fd;
fd=open(name,O_RDONLY); 

fd would be -1 if an error occurs at opening the file.

Would anyone be kind enough to explain this to me?
Thanks in advance:)

  • 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-04T03:01:45+00:00Added an answer on June 4, 2026 at 3:01 am

    Using fopen() allows you to use the C stdio library, which can be a lot more convenient than working directly with file descriptors. For example, there’s no built-in equivalent to fprintf(…) with file descriptors.

    Unless you’re in need of doing low level I/O, the stdio functions serve the vast majority of applications very well. It’s more convenient, and, in the normal cases, just as fast when used correctly.

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

Sidebar

Related Questions

i know that there isn't code inside my question, but i think this is
So there's this new cool thing, these NoSQL-databases. And so there's my data: Rows
I was doing this: (String[]) myTreeSet.toArray(); but that gives me a ClassCastException at runtime.
Is there a way to override a Java method that the only thing that
So I've been reading through Javascript - The Good Parts and one thing that
I know there's the built-in _stats function that gives you sum, count, min, max,
I don't think this is possible but I thought I'd throw it out there.
Is there anything wrong with checking so many things in this unit test?: ActualModel
I think there is a simple answer to this, but for some reason I
There are similar questions to this, but I don't think anyone has asked this

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.