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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:46:51+00:00 2026-05-28T16:46:51+00:00

Using just System Calls, how do you read a file upto the EOF and

  • 0

Using just System Calls, how do you read a file upto the EOF and in the process execute every line in the program, upto end of line.
Every line in my file, will have a program name that has to be executed.

 size_t fd1 = open("inputfile.txt", O_RDWR);
 char buf1[BUFFSIZE];
 while(read(fd1,buf1,10) != EOF) 
 {   
      if(fd1[MAXDATA] == "\n")

 }
  • 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-28T16:46:52+00:00Added an answer on May 28, 2026 at 4:46 pm

    i created a program with similar functionality recently:

    #include <stdio.h>
    #include <fcntl.h>
    #include <stdlib.h>
    #include <string.h>
    #define BUFFERSIZE 1024
    #define LINEMAXSIZE 2000
    void main(int argvc,char** argv)
    {
    int filedesc=open(argv[1],O_RDONLY);
    char buffer[BUFFERSIZE]; 
    
    char expression[LINEMAXSIZE]; //the line
    int exprindex=0;        //line index
    
    int count=read(filedesc,buffer,sizeof(buffer));//read bytes
    
    while(count!=EOF)
          {
                int i=0;
                while(i<count)
                {
                char c=buffer[i];
                if(c=='\n')
                {
                    expression[exprindex++]='\0';
                    char* line=strdup(expression);//create a new instance of the string
                    system(line); //execute the line 
                    exprindex=0;//set line index to 0
                }
                else
                {
                       expression[exprindex++]=c;
    
                    if(exprindex>=LINEMAXSIZE)
                    {
                    printf("Line Max length reached\n");
                    }
    
                }
    
            i++;
            }
    
    
            count=read(filedesc,buffer,sizeof(buffer));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to call a process using System.Diagnostics.Process, send it a parameter, just
I've done this function in C using system calls (open, read and write) to
I'm using a medical records system built on an Oracle database. Our vendor just
I am using Ubuntu 9.04 I just installed ruby and rails in my system
Just some background, sorry so long winded. I'm using the System.Data.SQLite ADO.net adapter to
I am sending file from client to server using TCP. To mark the end
I have few queries related to read()/pread() system calls in a multithreaded environment I
Using just an sql query is it possible to write the contents of a
How would I implement a binary search using just an array?
I am making a very simple preview window in JQuery using just an ordered

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.