This is a simple C program that mimics the basic functionality of the Unix/Linux cat command. It reads a file and prints its contents to the standard output.
cat.c– Main C source file containing the code to read and print a file.
To compile the program, use gcc:
gcc cat.c -o catRun the compiled program with a filename as an argument:
./cat <filename>./cat sample.txt- If no filename is provided, the program prints a usage message.
- If the specified file doesn't exist or can't be opened, an error message is shown.
- Read file content character by character.
- Simple and beginner-friendly code.
- Works with any readable text file.
- Does not support multiple files.
- No support for flags (e.g.,
-n,-E) like the originalcatcommand.