Reversing a linked list means re-arranging the next (connection) pointers. Head will point to the last node and the first node will point to NULL. Direction of other next pointers will change. If a linked list looks like this: After reversal, it will look like: Logic to Reverse a Linked List Take the first node … Continue reading “C Program to Reverse a Linked List”
Author: Srikanta
C Program to Count Characters, Words and Lines in a File
To get a quick summary of a file like total number of characters, words and limes, Linux already has a tool, wc. Here we’ll see how to write C program to get the similar information. Strategy to Count Characters, Words, Lines in a File Take input of a file name and open that file in … Continue reading “C Program to Count Characters, Words and Lines in a File”
C Program to Count Words in a String
For our purpose, a word is a set of consecutive characters without any white-space. For example, ‘qnaplus‘ is a word but ‘qna plus‘ has two words. Here we’ll see how to write C program to count the number of words in a string. We can think of a simple solution of counting the white spaces … Continue reading “C Program to Count Words in a String”
Count Occurrences of a Substring in a String in C
Here we’ll see how to find out the number of occurrences of a substring in a string. C string library (<string.h>) provides a function (strstr()) to check the presence of a substring. But it does not give you the number of instances of the substring inside a string. We’ll implement our own function with and … Continue reading “Count Occurrences of a Substring in a String in C”
C Program to Copy an Array to Another
We can not copy an array using simple assignment operation like any other primitive data types. Here we’ll discuss the techniques to copy an array from one to another. By Traversing We can copy an array by traversing the source array – coping one element in each iteration. This is simplest, most common and widely … Continue reading “C Program to Copy an Array to Another”