
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
Server Side Programming Articles - Page 2306 of 2651

75K+ Views
In C++, you can read data from a text file using file handling features provided by the header. This is useful when you want your program to read input stored in a file instead of typing it every time. To do this, you use a special object called ifstream (input file stream), which helps your program open the file and read its contents line by line or word by word. Reading a text file is helpful when: You want to process saved data (like scores, settings, or logs). You want to ... Read More

7K+ Views
Appending text means adding new content to an existing file without removing its current content. In C++, this can be done by opening the file in append mode and writing the specified content to it. Steps to Append Text to a Text File You need to follow the below steps to open a file in append mode and append the content to it: First of all, you need to include the header file. Them, create an ofstream object to write to the file. Open the file in append mode using the ios::app flag. Use the

1K+ Views
In C++, we can work with files to read, write, or even combine(append) their contents. Here, our task is to append the content of one text file to another. Imagine a scenario where we have two txt files which is named as 'source.txt' and 'destination.txt' files. So, with the help of these files we need to copy everything from the source file and append it at the end of the destination file. ExampleHere, we are giving an input as two text files as source.txt and destination.txt to append content in C++: source.txt file contains "Tutorials" destination.txt file contains "point" ... Read More

550 Views
In this problem, we will see how to print "Hello World" into the console, but we cannot write anything into the main function. This problem can be solved in different ways. Initially, we will create a global variable, then we will store the returned value of the printf() function into that variable. When printf() is executed, then it will be printed. You can print "Hello World" without using the logic inside the main() function in different ways, such as using Global Constructors, Class Object and macros, or preprocessor, etc. Using Global Constructor A global constructor is the constructor of a global object ... Read More

2K+ Views
The size of a file refers to the number of bytes it occupies in memory. In C, size of a file can be found by moving the file pointer to the end of the file and checking its position. The position indicates the number of bytes the file contains. The most common way to do this is by using two functions: fseek() (to move to the end) and ftell() (to get the current position, which is the size of the file). Syntax Following is the syntax is as follows: FILE *fp = fopen("file.txt", "rb"); fseek(fp, 0, SEEK_END); long size = ... Read More

179 Views
This is a C++ Program to Find Size of the Largest Independent Set (LIS) in a Given a Binary Tree.AlgorithmBegin. Create a structure n to declare data d, a left child pointer l and a right child pointer r. Call a function max() to return maximum between two integers. Create a function LIS() to return the size of the largest independent set in a given binary tree. Calculate size excluding the current node int size_excl = LIS(root->l) + LIS(root->r) Calculate size including the current node int size_incl = 1; if (root->l) ... Read More

463 Views
In this section we will see what are the differences between exit() and _Exit() in C and C++. In C the exit() terminates the calling process without executing the remaining code which is present after exit() function.In C++11, one new function is present called _Exit(). So what is the feature of this function? The exit() function performs some cleaning before terminating the program. It clears the connection termination, buffer flushes etc. This _Exit() function does not clean anything. If we test using atexit() method, it will not work.Let us see two examples where at first we are using exit() function, ... Read More

3K+ Views
In this article, we will see how we create and use 2D vectors with user-defined sizes. What is 2D Vector? In C++, a vector is a dynamic array used to store elements. The 2D vector is a vector of vectors and are used to create a dynamic two-dimensional array where the number of rows and the number of columns in each row can vary. Just like a 2D array, a 2D vector is used to store data in a tabular form such as matrices, grids, or tables. Structure of a 2D Vector A 2D vector is declared as: vector v; ... Read More

503 Views
A binary tree which has at most two children, specified as left child and right child. This is a C++ Program to find the lowest common ancestor in a Binary Tree.AlgorithmBegin Create a structure n to declare data d, a left child pointer l and a right child pointer r. Create a function to create newnode. Call a function LCA() to Find lowest common ancestor in a binary tree: Assume node n1 and n2 present in the tree. If root is null, then return. If root is not null there are two cases. ... Read More

206 Views
A binary tree which has at most two children, specified as left child and right child. This is a C++ Program to Find Deepest Left Leaf in a Binary TreeAlgorithmBegin. function deepestLLeafutil() find the deepest left leaf in a given binary tree: lvel is level of current node. maxlvel is pointer to the deepest left leaf node found so far isLeft Indicates that this node is left child of its parent resPtr is Pointer to the result If root is equal to Null ... Read More