
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1339 Articles for C

694 Views
Reversing a string means, moving first character to last, second character to second last and so on. In this article we will discuss how to reverse a string in place using C/C++ program. In the "in place" string reversing, we are not allowed take extra memory to store the string while running program. First of all, let's understand our problem statement:We are given a character string as input and we need to find and output the reverse string of the given string. For example: // Input : a character string "This is a string" //Output : Reverse of ... Read More

9K+ Views
In this section we will see how to convert a number (integer or float or any other numeric type data) to a string.The logic is very simple. Here we will use the sprintf() function. This function is used to print some value or line into a string, but not in the console. This is the only difference between printf() and sprintf(). Here the first argument is the string buffer. where we want to save our data.Input: User will put some numeric value say 42.26 Output: This program will return the string equivalent result of that number like “42.26”AlgorithmStep 1 − ... Read More

5K+ Views
C++ provides multiple ways to concatenate strings. Macro string concatenation is one of such way. In this article, we will learn how to use C++ preprocessor macros to concatenate strings and tokens. Understanding Macros in C++ In C++, macros are small pieces of code that are defined using the preprocessor directive #define. Macros are generally used to define variables, constants, functions, and other code blocks. When the code is compiled, the preprocessor replaces every occurrence of the macro with its defined value before actual compilation begins. Let's see an example of a macro definition and its usage. // ... Read More

782 Views
This is another tricky problem. In this program, we will see how to print a string using C where no quotation marks are used.Here we are using macro function. We are defining a macro function like#define getString(x) #xThe getString() is a macro function. It returns x by converting it into a string. The # before x is denoting that the function will convert x into a string.Input: Take one string without quote Output: Print that string into consoleAlgorithmStep 1:Take a string without quote Step 2: Use macro function to print it into a string Step 3: EndExample Code Live Demo#include #define ... Read More

605 Views
In this section we will see how to copy a string to other string without using strcpy() function. To solve this problem we can write our own function that can act like strcpy(), but here we will follow some trick. We will use another library function to copy a string into another.The logic is very simple. Here we will use the sprintf() function. This function is used to print some value or line into a string, but not in the console. This is the only difference between printf() and sprintf(). Here the first argument is the string buffer. where we ... Read More

15K+ Views
In this section we will see how to convert a number (integer or float or any other numeric type data) to a string.The logic is very simple. Here we will use the sprintf() function. This function is used to print some value or line into a string, but not in the console. This is the only difference between printf() and sprintf(). Here the first argument is the string buffer. where we want to save our data.Input: User will put some numeric value say 42.26 Output: This program will return the string equivalent result of that number like "42.26"AlgorithmStep 1: Take ... Read More

278 Views
In this post you can get some details where you can buy and view free drafts of some current and past C/C++ standards.C DocumentsC11:198 CHF (https://www.iso.org/standard/57853.html)Publicly at (http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf)Wikipedia Link (https://en.wikipedia.org/wiki/C11_(C_standard_revision))C99:Cannot Purchase (https://www.iso.org/standard/29237.html)Publicly at (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf)Wikipedia Link (https://en.wikipedia.org/wiki/C99)C90, C89, ANSI C, Standard CWikipedia Page: (https://en.wikipedia.org/wiki/ANSI_C)C++ DocumentsC++14:198 CHF (https://www.iso.org/standard/64029.html)Based On (https://www.iso.org/standard/29237.html)Wikipedia Link (https://en.wikipedia.org/wiki/ANSI_C)C++11:Cannot Purchase (https://www.iso.org/standard/50372.html)Publicly at (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf)Wikipedia Link (https://en.wikipedia.org/wiki/C%2B%2B11)C++03Wikipedia Page: (https://en.wikipedia.org/wiki/C%2B%2B03)C++89Wikipedia Page: (https://en.wikipedia.org/wiki/C%2B%2B)Read More

902 Views
A forward declaration informs the compiler that a class, function, or variable is declared earlier, but it will be defined later in the code. In this article, our task is to understand the forward declaration and when to use it. When is Forward Declaration Used in C/C++? The forward declaration can be used in C/C++ in the following cases: In C++, it is used for declaring a friend function. Using the forward declaration, we can reduce the header files that we include in the code. When ... Read More

893 Views
The size of a struct type element taken by sizeof() is not always equal to the size of each individual member. Sometimes the compilers add some padding to avoid alignment issues. So the size may change. The padding is added when a structure member is followed by a member with a larger size or at the end of the structure. Different compiler has different types of alignment constraints. In C standard, the total alignment structure depends on the implementation.Case 1In this case the double z is 8-byte long, which is larger than x (4-byte). So another 4-byte padding is added. ... Read More

3K+ Views
In this section we will see how to see the Host name and IP address of the local system in an easier way. We will write a C program to find the host name and IP.Some of the following functions are used. These functions have different task. Let us see the functions and their tasks.FunctionDescriptiongethostname()It finds the standard host name for the local computer.gethostbyname()It finds the host information corresponding to a host name from host databaseiten_ntoa()It converts an IPv4 Internet network address into an ASCII string into dotted decimal format.Example Code#include #include #include #include #include ... Read More