Git Product home page Git Product logo

cat-program-with-system-calls's Introduction

CAT Command Implementation in C

This program is designed to imitate the implementation of the cat command using various system calls like open(), close(), read(), write(). The program is completely written in C, and uses the default compiler for FreeBSD which uses the command cc to get compile.

How to run the program

  • Clone or download this repository.
  • Navigate to the directory and open it on terminal.
  • Compile the source code using make.
  • Now you have an executable with the name of mycat.
  • You can remove the executable using make clean.

System Calls

  • open(): The open() system call opens the file specified by file name. and takes a second argument of flags.
  • close(): The close() system call closes the file after finishing I/O operation
  • read(): read() reads up to an x number of bytes from a certain file into the buffer. A buffer has to be created first.
  • write(): write() writes up to an x number bytes from the buffer starting at a certain point to the file referred to in the function declaration.
  • perror(): perror() prints a system error message.

Flags

  • O_RDONLY: short for Read Only.

Experiment

  • ./mycat file1.txt file2.txt file3.txt: output from each file will be printed to standard output.
  • ./mycat file100.txt: an error will be printed to standard output.
  • ./mycat: Program will take input from the user and then the output will be printed to standard output.
  • ./mycat < file1 > file2: Input will be read from file1 and written into file2.
  • ./mycat file1 | grep string1: A line containing "string1" will be printed.

Assignment By: Ahmed SalahEldin Farouk Elkashef - 1410216.

cat-program-with-system-calls's People

Contributors

ahmedelkashev avatar

Watchers

 avatar  avatar

Forkers

ahmmkh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.