Category: Tutorials

The Typedef and using Keywords in C and C++

The typedef or “type definition” is a keyword in C or C++ Programming language that allows declaring different names for types such as int or char. It specifies that that the declaration is a typedef declaration rather than a variable or function declaration. In C/C++, any valid data type can be aliased so that it can be referred to with a different identifier.

Read More

Difference between char[] and char* in C? Character Array and Pointer

Generally, the following two statements about char[] and char * in C are considered confusing and understanding the difference between them is important. The first statement puts the literal string “mycplus” in read-only memory and copies the string to newly allocated memory on the stack. The second statement is known as static string allocation and definition.

Read More

C++ Vector – std::vector – A Complete Guide with Examples and Programs

Vectors in C++ are one of the most powerful sequence containers, offering dynamic resizing and memory management capabilities. In this comprehensive guide, we’ll explore everything from vector initialization to advanced vector manipulation, making it an essential resource for C++ developers aiming to master this versatile container.

Read More

Ternary Operator with examples in C

In C Programming, ternary operator allows executing different code depending on the value of a condition. The returned value is the result of the expression when the code is executed. The main advantage of using ternary operator is to reduce the number of lines of code and improve the performance of application. In C, the real utility of ternary operator is that it is an expression instead of a statement i.e. you can have it on the right-hand side (RHS) of a statement. So you can write certain code statements more concisely.

Read More

File Handling in C++

In C++, files are referred to as flow of streams (data) into and out of programs. Streams are basis data type to handle all input and output (I/O) operations. There are different kinds of streams of data flow for input and output. Each stream is associated with a class, which contains member functions and definitions for dealing with that particular kind of flow.

Read More

Ternary Operator with examples in C++

In C++, ternary operator allows executing different code depending on the value of a condition, and the result of the expression is the result of the executed code. The ternary operator uses 3 operands. It evaluates a condition and after that chooses one of its two branches to execute, depending upon the result of condition. The symbol for ternary operator is “? :”. The syntax for the ternary operator is: ? : ;

Read More