Tag Archives: cpp-library

Builtin functions of GCC compiler

These are three important builtin functions in GCC compiler: _builtin_popcount(x): This function is used to count the number of one’s(set bits) in an integer. Example: if x = 4 binary value of 4 is 100 Output: No of ones is 1. Output: Count of 1s in binary of 5 is 2 __builtin_clz(x): This function is… Read More »

Array Type Manipulation in C++

This article demonstrates some of the inbuilt functions that can be used to query and manipulate array types, even a multidimensional array. These functions can be useful in cases we need information or manipulate array we initiated with different dimensions. These functions are defined in header file . Some of the functions include : is_array()… Read More »

C program to demonstrate fork() and pipe()

Write Linux C program to create two processes P1 and P2. P1 takes a string and passes it to P2. P2 concatenates the received string with another string without using string function and sends it back to P1 for printing. Examples: Other string is: forgeeks.org Input : www.geeks Output : www.geeksforgeeks.org Input : www.practice.geeks Output… Read More »

strdup() and strdndup() functions in C.

The strdup() and strndup() functions are used to duplicate a string. strdup() : Syntax : char *strdup(const char *s); This function returns a pointer to a null-terminated byte string, which is a duplicate of the string pointed to by s. The memory obtained is done dynamically using malloc and hence it can be freed using… Read More »

Complex numbers in C++ | Set 2

We introduced and discussed the concept in Complex numbers in C++ | Set 1 The remaining functions with example are discussed here: log() – It is used to return the log of the complex number. Output: The log of (-1,0) is (0,3.14159) cos() – It computes complex cosine of a complex value z. Mathematical definition… Read More »

exec family of functions in C

The exec family of functions replaces the current running process with a new process. It can be used to run a C program by using another C program. It comes under the header file unistd.h. There are many members in the exec family which are shown below with examples. execvp : Using this command, the created… Read More »

Inbuilt library functions for user Input | scanf, fscanf, sscanf, scanf_s, fscanf_s, sscanf_s

scanf() : The C library function int scanf (const char *format, …) reads formatted input from stdin. Syntax: int scanf(const char *format, …) int: return type format: string that contains the type specifier(s) “…” (ellipsis): indicates that the function accepts a variable number of arguments Each argument must be a memory address where the converted… Read More »

Complex numbers in C++ | Set 1

The complex library implements the complex class to contain complex numbers in cartesian form and several functions and overloads to operate with them. real() – It returns the real part of the complex number. imag() – It returns the imaginary part of the complex number. Output: Real part: 10 Imaginary part: 2 abs() – It… Read More »

Chrono in C++

Chrono library is used to deal with date and time. This library was designed to deal with the fact that timers and clocks might be different on different systems and thus to improve over time in terms of precision. The unique thing about chrono is that it provides a precision-neutral concept by separating duration and… Read More »

std:: valarray class in C++

C++98 introduced a special container called valarray to hold and provide mathematical operations on arrays efficiently. It supports element-wise mathematical operations and various forms of generalized subscript operators, slicing and indirect access. As compare to vectors, valarrays are efficient in certain mathematical operations than vectors also. Public member functions in valarray class : 1. apply()… Read More »

memset() in C with examples

memset() is used to fill a block of memory with a particular value. The syntax of memset() function is as follows : // ptr ==> Starting address of memory to be filled // x ==> Value to be filled // n ==> Number of bytes to be filled starting // from ptr to be filled… Read More »