Found 26504 Articles for Server Side Programming

Ternary operator ?: vs if…else in C/C++

Aman Kumar
Updated on 09-Jun-2025 18:40:42

792 Views

In C/C++, both ternary operator and if-else statements are conditional statements: A condition statement expresses the relationship between two ideas or events. Where one is dependent on the other. If the condition is true, the if statement will return; otherwise, the else statement will return. Ternary Operator We know that the ternary operator is the conditional operator. Using this operator, we can check some conditions and do some tasks according to those conditions. Without using the ternary operator, we can also use the if-else conditions to do the same. Following is The Syntax of the Ternary Operator: condition ? expression_if_true ... Read More

C Program to find sum of two numbers without using any operator

Aman Kumar
Updated on 09-Jun-2025 18:40:20

1K+ Views

In this article, we Implement the C program to find the sum of two numbers without using any Operator. Find Sum of Two Numbers Without Using Any Operator in C This problem is tricky. To solve this problem we are using the minimum width features of the printf() statement. We can use '*' which indicates the minimum width of output. For example, in this statement "printf("%*d", width, num);", the specified 'width' is substituted as *, and 'num' is printed within the minimum width specified. If the number of digits in 'num' is less than the provided 'width', the output will ... Read More

Execution of printf with ++ operators in C

Aman Kumar
Updated on 09-Jun-2025 18:40:02

2K+ Views

In the C programming language, the printf() function is used to print ("character, string, float, integer, octal, and hexadecimal values") to the output screen. To demonstrate the value of an integer variable, we use the printf() function with the %d format specifier. Let's see a C statement and guess the result: printf("%d %d %d", i, ++i, i++); Here, in the above C statement, both 'i' and 'i++' are in the argument list; this statement causes undefined behaviour. The sequence in which the arguments are evaluated is not specified; orders may alter depending on the compiler. At different times, a ... Read More

Stack Unwinding in C++

Aman Kumar
Updated on 06-Jun-2025 14:11:37

2K+ Views

When we call some functions, the call stack stores the address, and after returning, it pops the address to resume work. What is Stack Unwinding Stack unwinding refers to the process of removing function call frames from the function call stack during runtime, wherein local objects are destroyed in the reverse order of their construction. Why Stack Unwinding Occurs? Stack unwinding occurs when an exception occurs in a function and is not handled immediately in that function. The program control goes back through each function step by step, cleaning up any temporary resources used by each function. How Unwinding Works? ... Read More

What happen if we concatenate two string literals in C++?

Aman Kumar
Updated on 06-Jun-2025 14:10:58

158 Views

In this article, we will explore what happens when we concatenate two string literals in C++. There are two important points to remember when concatenating strings in C++. Concatenation is another property of the string and string literals: let's see the following two properties below: If x + y is the expression of string concatenation, where x and y are both strings. Then the result of this expression will be a copy of the characters of string x followed by the characters of string y. Either x or y can be ... Read More

StringStream in C++ for Decimal to Hexadecimal and back

Aman Kumar
Updated on 06-Jun-2025 14:18:31

907 Views

In this article, we will see how to convert a Decimal to a Hexadecimal string and versa in C++. For this conversion, we are using the string stream feature of C++. You can use StringStreams for formatting, parsing, converting a string into numeric values, and more. The Hex is an I/O manipulator. It takes a reference to an I/O stream as a parameter and returns a reference to the string after manipulating it. Implementation of converting Decimal to Hexadecimal In the following example, we will see how to convert decimal numbers or hexadecimal numbers in C++. #include #include ... Read More

Stringize and Token-pasting operator in C

Aman Kumar
Updated on 06-Jun-2025 14:18:52

3K+ Views

In this article we will see what are the Stringize operator and Token Pasting operator in C. The stringize operator (#) and the token pasting operator (##) are preprocessor operators used within macros for text manipulation. It sends commands to compiler to convert a token into string. Stringize Operator (#) The stringize operator (#) is a preprocessor operator that converts the micros parameter into a string literal. The preprocessor encloses the actual argument passed to the macro in double quotes, effectively convert it into a string. Syntax Following is the syntax of Stringize Operator: #define MACRO_NAME(arg) #arg ExampleIn ... Read More

How to find length of a string without string.h and loop in C?

Aman Kumar
Updated on 04-Jun-2025 18:53:35

657 Views

C provides libraries for string operations such as the string.h header file that contains a strlen() function, which counts the length of a string. Otherwise, a loop can be used to count the string length. There are also different ways to find the length of a string apart from the above two methods. So, basically, in this article, we will learn how to find the length of a string without string.h and loop in C. Find Length of a String Without string.h and Loop in C There are the following ways to find the string's length without using the string.h ... Read More

How to convert std::string to LPCWSTR in C++?

Aman Kumar
Updated on 04-Jun-2025 18:53:51

3K+ Views

std::string The std::string is a class of C++ Standard Library (STL) that represents a string (sequence of characters). It is used to handle strings with better memory management, i.e., it provides dynamic memory management for strings and supports a rich set of in-built functions for string manipulation. Syntax Following is the syntax of string: string str = "tutorialspoint"; std::LPCWSTR The LPCWSTR stands for Long Pointer to Constant Wide STRing. It is a constant string of 16-bit Unicode characters, which may be null-terminated. It is the same as a string but with wide characters. Syntax Following is the syntax of ... Read More

How to convert std::string to LPCSTR in C++?

Aman Kumar
Updated on 04-Jun-2025 17:51:29

4K+ Views

std::string The std::string is a class of C++ Standard Library (STL) that represents a string (sequence of characters). It is used to handle strings with better memory management, i.e., it provides dynamic memory management for strings and supports a rich set of in-built functions for string manipulation. Syntax Following is the syntax of string: string str = "tutorialspoint"; std::LPCSTR LPCSTR stands for Long Pointer to Constant String. It is a constant, null-terminated string of ANSI (narrow) characters (8-bit characters). In contrast to LPCWSTR, which stores wide characters (Unicode/UTF-16), LPCSTR is used in Windows API functions to store regular char-based ... Read More

Advertisements