This repository contains a simple C program called readWriteFile.c
that demonstrates how to read and write data to a file using the C programming language.
The readWriteFile.c
program performs the following actions:
- Opens a file called
myfile.txt
in write mode. - Writes a string "Hello Zedro" to the file.
- Closes the file.
- Reopens the file in read mode.
- Reads the contents of the file into a character array.
- Prints the contents of the file to the console.
- Closes the file.
The program uses fopen
, fputs
, fgets
, and fclose
functions from the stdio.h
library to manipulate the file. These functions provide a simple and straightforward way to work with files in C.
To use this program, follow these steps:
- Compile the
readWriteFile.c
file using a C compiler (e.g., GCC). - Run the compiled executable.
- The program will create a file named
myfile.txt
and write "Hello Zedro" to it. - The program will then read the contents of
myfile.txt
and print it to the console.