Enumeration is a user defined datatype in C/C++ language. It is used to assign names to the integral constants which makes a program easy to read and maintain. The keyword “enum” is used to declare an enumeration.The following is the syntax of enums.enum enum_name{const1, const2, ....... };Here, enum_name − Any ... Read More
We use gcc and g++ compilers in different times. Here we will see what are the differences between gcc and g++.The gcc is GNU C compiler, and g++ is GNU C++ compiler. The main differences are like below −gcc can compile *.c or *.cpp files as C and C++ respectivelyg++ ... Read More
Here we will see how to compile C++ program using GCC (GNU C Compiler). Let us consider, we want to compile this program.Example#include<iostream> using namespace std; main() { cout << "Hello World. This is C++ program" << endl; }If this is a C program, we can compile with GCC ... Read More
Here we will see how to prevent inheritance in C++. The concept of preventing the inheritance is known as final class.In Java or C#, we can use final classes. In C++ there are no such direct way. Here we will see how to simulate the final class in C++.Here we ... Read More
Sometimes we may see some numeric literals, which is prefixed with 0. This indicates that the number is octal number. So octal literals contain 0 at the beginning. For example, if an octal number is 25, then we have to write 025.Example#include <stdio.h> int main() { int a = ... Read More
Here we will see the wprintf() and wscanf() functions in C. These are the printf() and scanf() functions for wide characters. These functions are present in the wchar.hThe wprintf() function is used to print the wide character to the standard output. The wide string format may contain the format specifiers ... Read More
Here we will see one interesting problem. In this problem, we will see how to print Christmas tree randomly. So the tree will be flickering like Christmas tree lights.To print a Christmas tree, we will print pyramids of various sizes just one beneath another. For the decorative leaves a random ... Read More
Here we will see, why we should use the strict aliasing in C. Before discussing that part, let us see one code, and try to analyze the output.Example#include<stdio.h> int temp = 5; int* var = &temp; int my_function(double* var) { temp = 1; *var = 5.10; //this will change the value of temp return (temp); } main() { printf("%d", my_function((double*)&temp)); }Output1717986918If we ... Read More
Here we will see how to apply the multi-threading concept to search one element in an array. Here the approach is very simple. We will create some threads, then divide the array into different parts. Different thread will search in different parts. After that, when the element is found, enable ... Read More
Here we will see how to print numbers in a correct sequence using different threads. Here we will create n number of threads, then synchronize them. The idea is, the first thread will print 1, then second thread will print 2 and so on. When one thread is trying to ... Read More
In C we have used Files. To handle files, we use the pointer of type FILE. So the FILE is a datatype. This is called the Opaque datatype. So its implementation is hidden. The definition of the FILE is system specific. This is the definition of FILE in Ubuntu System ... Read More
Here we will see, what are the basic differences between fundamental data types and derived datatypes in C or C++.Fundamental DatatypesDerived DatatypesThe fundamental datatypes are also known as primitive datatypes.Derived datatypes are composed of fundamental datatypes.Some fundamental datatypes are int, char, float, void etc.Derived datatypes are arrays, structures, pointers etc.Integer ... Read More
Here we will see the Hygienic Macros in C. We know the usage of macros in C. But sometimes, it does not return the desired results because of accidental capture of identifiers.If we see the following code, we can see that it is not working properly.Example#include<stdio.h> #define INCREMENT(i) do { ... Read More
Here we will see some incompatibilities between C and C++. Some C codes that can be compiled using C compiler, but does not compile in C++ compiler. And also returns error.We can define function using a syntax, that optionally specify the argument types after the argument list.Example#include<stdio.h> void my_function(x, y)int ... Read More
Here we will see the effect of fork() and exec() system call in C. The fork is used to create a new process by duplicating the calling process. The new process is the child process. See the following property.The child process has its own unique process id.The parent process id ... Read More
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more