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”

C Program to Delete Element from an Array

Here we’ll see how to delete an element of a particular position from an array. Deleting element means left-shifting the right elements starting from the position. The above program first takes the array as input and the position of an element to be deleted. Then it prints the array before and after deleting the element. … Continue reading “C Program to Delete Element from an Array”

0
0
0
2
0
0