VaultBy ENSAMIENParrainage
Note2025-09-24

DSA en C

CHOUBIK Houssam

Ressources

Guide to DSA in C

Books : Data Structure Book Fundamentals of Data Structures in C - Ellis Horowitz

Structures in C

nb : we shouldnt declare a struc or table in the middle of the program , always declare it in the top.

File handling in C

  • fprintf to print
  • fscanf to read

In C, you can create, open, read, and write to files by declaring a pointer of type FILE, and use the fopen() function:

FILE *fptr;  
fptr = fopen(_filename_, _mode_);

FILE is basically a data type, and we need to create a pointer variable to work with it (fptr). For now, this line is not important. It's just something you need when working with files.

To actually open a file, use the fopen() function, which takes two parameters:

Parameter Description
filename The name of the actual file you want to open (or create), like filename.txt
mode A single character, which represents what you want to do with the file (read, write or append):

w - Writes to a file
a - Appends new data to a file
r - Reads from a file

    Type at least 2 letters. ↑ ↓ to move, Enter to open.