C Program to List All Files Including Subdirectories

In the previous article, we saw how to list all files in a particular directory. That program does not display the files of the subdirecties. Here we’ll see how to display the files of the current direcory and of the subdirectories. The directory stucture could be arbitarily nested. The program here will display the files … Continue reading “C Program to List All Files Including Subdirectories”

C Program to List All Files in a Directory

Listing all files in a directory is a very common programming requirement. Here we’ll see how to read and display all file names in a directory using C directory entry (dirent) library. This program first opens the current directory (“.”) using opendir() function. In a loop, each entry in the directory is read using readdir() … Continue reading “C Program to List All Files in a Directory”

C Program to Replace All Occurrences of a Character by Another One in a String

Here we’ll see how to replace all occurrences of a character by another one in a string. Read also: C program to remove all occurrences of a character. This program first takes a string as input, then two characters. First character will be replaced by the second one. The replace_char() function replaces the find character … Continue reading “C Program to Replace All Occurrences of a Character by Another One in a String”

C Program to Remove all Occurences of a Character from a String

Here we’ll see how to remove all occurences of a character from a string. For example, if we remove the character ‘o‘ from the string “The quick brown fox jumps over the lazy dog“, the result will be “The quick brwn fx jumps ver the lazy dg“. All four occurneces of ‘o’ removed from the … Continue reading “C Program to Remove all Occurences of a Character from a String”

C Program to Remove All Occurrences of a Number from an Array

In the previous article we saw how to remove an element of a particular position from an array. Here we’ll see how we can remove all occurrences of a number. For example, if an array has the number 100 three times, all three ocurrences of 100 will be removed. The holes created by the removal … Continue reading “C Program to Remove All Occurrences of a Number from an Array”

0
1
1
3
7
1