3

I need to write a C program that accepts three command line arguments:

  1. input file one
  2. input file two
  3. name of output file

The program needs to read the data in from files 1 and 2 and concatenate the first file followed by the second file, resulting in the third file.

This seems like it should be pretty easy, but one of the stipulations of the assignment is to only use low-level I/O.

What exactly does that mean (low-level I/O)?

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
  • Not a bad question. OP did not ask for code. – haccks Oct 29 '13 at 08:40
  • 1
    I never said it was a bad question. – sukhvir Oct 29 '13 at 08:47
  • 'low-level I/O' would mean, to me, drivers, and the whole gunge of OS and hardware-specific interrupts and DMA that goes with them. It's an insufficiently-specified assignment that I would refuse to process without further clarification. – Martin James Oct 29 '13 at 09:18

2 Answers2

9

To answer the only question (what is low-level I/O) it probably means operating system native input/output functions.

In POSIX this would be e.g. open(), close(), read() and write().

On Windows e.g. CreateFile(), CloseHandle(), ReadFile() and WriteFile().

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • @Sukminder On Windows e.g. `_open` etc. are not the native WIN32 functions. They are instead using the native WIN32 function under the hood. It all depends on how low-level you want to go I guess. – Some programmer dude Oct 29 '13 at 09:10
  • Is it correct that _“C language is closely related to Unix and Unix-like systems", so all the functions designed to perform I/O operations at low level are in fact wrappers of corresponding OS services._? What about _On Windows_ vs _in POSIX_ – Cătălina Sîrbu Nov 10 '20 at 20:25
  • 1
    @CătălinaSîrbu While C was born on UNIX (from which POSIX followed), the C programming language have since its standardization in the 1980's been totally independent from operating system. The lowest-level I/O functions in C are probably `fread` and `fwrite`, which aren't "OS-level" low-level. – Some programmer dude Nov 10 '20 at 20:31
  • Thanks! I forgot to ask Why do we need to use low level I/O if there is a high level implementation of these functionalities? Is for better performance? I've read that they are already tuned for performance even if they have the buffer and line translation occurs – Cătălina Sîrbu Nov 10 '20 at 21:18
  • 1
    @CătălinaSîrbu Performance *could* be an issue, but it's not always the main reason. Sometimes it's just not possible to use something else. For example when using pipes, sockets, serial ports, or other similar things that aren't abstracted by the C library. – Some programmer dude Nov 11 '20 at 06:26
0

Low level basically stands for OS level. This can be done by using System calls. Application developers often do not have direct access to the system calls, but can access them through an application programming interface (API). The functions that are included in the API invoke the actual system calls. By using the API, certain benefits can be gained:

Portability: as long a system supports an API, any program using that API can compile and run.

Ease of Use: using the API can be significantly easier then using the actual system call.

For more information on system calls have a look here ,here and here.

For your program have a look here.

neo
  • 969
  • 1
  • 11
  • 23