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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:19:04+00:00 2026-06-12T09:19:04+00:00

I wrote a C program. (Question at bottom of page) I can provide actual

  • 0

I wrote a C program. (Question at bottom of page) I can provide actual code, but I don’t think it is necessary for this question to be answered.

Used a while loop with fgets to get sizeof line
Assigned that fgets to line[255] in the fgets
Assigned the line to a char* (inside the loop)
Printf the char* (also inside the loop)

C program outputs as expected.

I used strace -o x.txt ./a.out to see what is going on behind the scenes.

I see this: (of course there is a lot more garble above/below it I don’t understand)

read(3, "text\nMore text\nEven more text"..., 4096) = 72
write(1, "text\n",5) = 5
... more of the write() = #
read(3, "", 4096) = 0
close(3)

Question:

  1. I get the write(1=stdout, "text to print", #of char) or is this # of byte?

  2. I do not understand the read(3, "", 4096) = 0

I know 0=stdin, 1=stdout, 2=stderr, do not know what 3 means – maybe this is the file?
I do not know why it is doing another read, and I assume 4096 is what the buffer size?
My best guess is that since it is saying = 0 because its EOF ?

  • 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-12T09:19:05+00:00Added an answer on June 12, 2026 at 9:19 am
    1. Number of chars

    2. The file you have opened. 4096 is buffer size. Last read has failed to read any bytes (0 bytes).

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

Sidebar

Related Questions

This is a very basic question for JUnit testing. I wrote a program which
This is question about Objective-C. I wrote the program that uses regular expression with
Question: why can't it find -lGL? Info: I wrote a program as guided by
I wrote a program which can generate regex like this a(b|)c . Actually, it
this is a general question about GUIs. I never wrote a program with GUI,
I wrote a program which can generate DFAs. But the DFAs are slightly incorrect.
This is the question. write a program that prompts the user to input five
I wrote a program called Hello.py that looks like this: import pygame, sys from
I wrote a program to multiply, divide, add, and subtract fractions..I just can't figure
I wrote this program: #include <stdio.h> /*Part B Write a program that: defines an

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.