Appending to a means adding the new content at the end of the file retaining the old content intact. If the file is opened in normal write mode, the new content will replace the old content. Here we’ll see how to open a file in append mode Logic to Append to a File Declare a … Continue reading “C Program to Append to a File”
Category: C
C Program to Write to a File
Writing to a file is a basic programming requirement. All information of a running program is generally stored in the physical memory or RAM. They are lost with the termination of the program. If you need to persist some information, you need to store it in some persistent storage like a disk. Writing to a … Continue reading “C Program to Write to a File”
C Program to Count Words in a File
We discussed different ways to count words in a string in this article. Here we’ll extend that to count all words in a file. We can think of a file as a collection of lines. We’ll count words of each line one by one and add them up. This program first opens the file, sample.txt, … Continue reading “C Program to Count Words in a File”
C Program to Implement Stack Using Array
Stack is a collection of data elements serving Last In First Out (LIFO) functionality – whichever element comes last will be removed first. This data structure helps solve a number of real life problems. Like undo / redo functionalities, recursive function implementation, solving arithmetic equations etc. Basic Stack Operations Push: Inserting a new element into … Continue reading “C Program to Implement Stack Using Array”
C Program to Implement Queue Using Circular Array
Queue is one of the fundamental data structures used in computer science. As the very nature of a queue, whoever comes first will be served first. That’s why it is called First In First Out (FIFO) data structure. Event Queue or Message Queue are very common examples of this data structure. We’ll see here how … Continue reading “C Program to Implement Queue Using Circular Array”