Here we will see some interesting facts about C programming. These are like below. Sometimes the case labels of some switch statement can be placed inside if-else statement., , The array[index] can be written as index[array]. The reason is array elements are accessed using pointer arithmetic. The value of array[5] is *(array + 5). If this is in the reverse order like 5[array], then also thi.....
In C++, there is no direct way to check the environment architecture. There are two Macros for Windows systems, that can be used to check the architecture. These macros are _WIN64, and _WIN32. When the system is 64-bit, then the _WIN64 will be 1, otherwise the _WIN32 will be 1. So using macro checking, we can identify the architecture , ,
Here we will see, how to terminate the threads in C++11. The C++11 does not have direct method to terminate the threads. The std::future<void> can be used to the thread, and it should exit when value in future is available. If we want to send a signal to the thread, but does not send the actual value, we can pass void type object. To create one promise object, we have to follow this s.....
Here we will see how to compare two floating point data using C++. The floating point comparison is not similar to the integer comparison. To compare two floating point values, we have to consider the precision in to the comparison. For example, if two numbers are 3.1428 and 3.1415, then they are same up to the precision 0.01, but after that, like 0.001 they are not same. To compare using t.....
In C++, the inline keyword is used in different places. To create inline variables, or inline namespace, and as well as to create inline methods or functions. C++ inline function is powerful concept that is commonly used with classes. If a function is inline, the compiler places a copy of the code of that function at each point where the function is called at compile time. Any change to an .....
Here we will see some different types of variable declaration based on integer pointers integer constants and the integer constant pointers. To determine them we will use the Clockwise/Spiral Rule. By discussing the terms, we can understand the rules also. The const int *. This is used to tell the compiler that this is a pointer type variable, and this can store address of some constant int.....
In C the strings are basically array of characters. In C++ the std::string is an advancement of that array. There are some additional features with the traditional character array. The null terminated strings are basically a sequence of characters, and the last element is one null character (denoted by ‘\0’). When we write some string using double quotes (“…”).....
Here we will see how we can create a system, where we will create one client, and a server, and the client can send one string to the server, and the server will reverse the string, and return back to the client. Here we will use the concept of socket programming. To make the client server connection, we have to create port. The port number is one arbitrary number that can be used by the so.....
The semaphore is a concept of process or thread synchronization. Here we will see how to use the semaphores in real programs. In Linux system, we can get the POSIX semaphore library. To use it, we have to include semaphores.h library. We have to compile the code using the following options. , We can use sem_wait() to lock or wait. And sem_post() to release the lock. The semaphore initialize.....
Here we will see how to generate random number in given range using C. To solve this problem, we will use the srand() function. The current time will be used to seed the srad() function. This function cannot generate random number in any range, it can generate number between 0 to some value. So for it, we have to follow one trick. We will generate random number in between 0 to (upper &ndash.....
Sign up now to get your own personalized profile!
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more