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”
SQL Query to Find the N-th Highest Salary
This is the extension of the article of finding the second highest salary. Here we’ll see how to find the N-th highest salary. It is more generic version which is applicable for second highest also. Lets consider this employee table. DBMS Independent Way Here we’ll not use any DBMS specific keywords. This SQL query should … Continue reading “SQL Query to Find the N-th Highest Salary”
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”
Linux Command to Rename a File or Directory
Standard Linux distributions don’t generally come with a rename command. You can install the rename package though. But the standard mv (move) command can be used to rename a file or directory very easily. The mv command will be available in almost all Linux. We generally use the mv command to move a file or … Continue reading “Linux Command to Rename a File or Directory”