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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:06:20+00:00 2026-05-27T03:06:20+00:00

The question is Implement a function char* readLine(); which returns single lines from a

  • 0

The question is

Implement a function char* readLine(); which returns single lines from
a buffer. To read the buffer, you can makes use of a function int
read(char* buf, int len) which fills buf with upto len chars and
returns the actual number of chars filled in. Function readLine can be
called as many times as desired. If there is no valid data or newline
terminated string available, it must block. In order to block, it can
use read function which in turn will block when it doesn’t have
anything to fill the buf.

I don’t know how to proceed and what kind of approach is expected.
I could not understand what the interviewer expects here. I just need direction to move ahead and not the exact function.

  • 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-05-27T03:06:20+00:00Added an answer on May 27, 2026 at 3:06 am

    Allocate an appropriately sized buffers.

    If you don’t have characters in your read buffer, read in a new chunk.

    If the next character from the read buffer is a newline, return the result buffer.

    If the result buffer is full, bug out and whine about lines being too long.

    Otherwise, add the next character from the read buffer into the result buffer.

    NOTE: The answer to the question as asked is a security issue waiting to happen, and also a potential memory leak.

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

Sidebar

Related Questions

How can I implement a diff function, such as Stack Overflow's question revision history?
Question Implement a function bool chainable(vector<string> v) , which takes a set of strings
This is a further question based on this answer: How can I implement a
How can I filter (replace empty() function) in my div container using mootools? Question
The solution to a previous question ( How to implement Maintenance Mode on already
Quick question: Would it be a good or a bad idea to implement my
I had asked a question on how to implement real time updates in ASP.NET
I am looking to implement a data-driven wizard with the question tree stored in
I'm trying to implement the answer to this SO question . The problem is:
I asked this question a while back but now I'm looking to implement 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.