We don’t have millisecond level control in the sleep() function. But in Linux we can implement our own function that will take duration in milliseconds as input and sleep for that duration. Using usleep() The usleep() function takes the duration in micro seconds as input. We can have a wrapper around this usleep() function that … Continue reading “C Program to Sleep in Milliseconds”
Category: C
C Program to Delete Linked List
In my previous article I showed how to create a linked list. Now if you no longer need the linked list in your program, you have to delete that. Otherwise, it will lead to memory leak. Here we’ll see how to delete linked list completely. C Function to Delete Linked List This function takes the … Continue reading “C Program to Delete Linked List”
Static Members in C++ Template Class
We generally use static members in C++ class to maintain something that is not object specific, rather class specific. For example, if we want to maintain a counter about how many objects are created from a class, we keep a static counter in the class. In the class constructor, we increment the counter and we … Continue reading “Static Members in C++ Template Class”
How to find position of a digit in a number in C programming?
This program will find out the position of a digit in a number. If the digits exists in multiple positions, this program will find all positions. For example digit 4 is present in 41234253 at 4th and 8th positions from left. He is the Output: Logic is simple: in every iteration we do modulo operation … Continue reading “How to find position of a digit in a number in C programming?”
C Program to Find Second Largest Element in an Array
Here we’ll see the possible solutions of finding the second largest element in an array. By Sorting the Array: Easy solution that I can think of to find the second largest element in an array is to first sort the array and then pick the second or second last element of the array depending on … Continue reading “C Program to Find Second Largest Element in an Array”