- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 7401 Articles for C++
1K+ Views
Here we will see the precedence of postfix++ and prefix++ in C or C++. The precedence of prefix ++ or -- has higher priority than dereference operator ‘*’ and postfix ++ or -- has priority higher than both prefix ++ and dereference operator ‘*’.When ptr is a pointer, then *ptr++ indicates *(ptr++) and ++*prt refers ++(*ptr)Example Live Demo#include using namespace std; int main() { char arr[] = "Hello World"; char *ptr = arr; ++*ptr; cout
193 Views
A scope is a region of the program and broadly speaking there are three places, where variables can be declared −Inside a function or a block which is called local variables, In the definition of function parameters which is called formal parameters.Outside of all functions which is called global variables.We will learn what is a function and it's parameter in subsequent chapters. Here let us explain what are local and global variables.Local VariablesVariables that are declared inside a function or block are local variables. They can be used only by statements that are inside that function or block of code. ... Read More
326 Views
In this section we will see what is the line spacing in C or C++. Sometimes we put some single line comment using double slash “//”. The one-line comment is basically ends when we move to the next line. But if we put back slash at the end of some single line comment, then what will be the effect?When back slash is used it continues to the next lie. So after the comment line, if there are some line after comment, it will also be ignored. Let us see an example.Example Live Demo#include using namespace std; int main () { ... Read More
423 Views
A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.This is a C++ program to Implement Hash Tables chaining with doubly linked lists.AlgorithmFor insert:Begin Declare Function insert(int k, int v) int hash_v= HashFunc(k) HashTableEntry *en = ht[hash_v] if (en == NULL) en = new HashTableEntry en->d = v en->k = k ... Read More
18K+ Views
A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.This is a C++ program to Implement Hash Tables.AlgorithmBegin Initialize the table size T_S to some integer value. Create a structure hashTableEntry to declare key k and value v. Create a class hashMapTable: Create a constructor hashMapTable to create the table. Create a hashFunc() function which return key mod T_S. Create a function Insert() to insert element at ... Read More
5K+ Views
To write a binary file in C++ use write method. It is used to write a given number of bytes on the given stream, starting at the position of the "put" pointer. The file is extended if the put pointer is current at the end of the file. If this pointer points into the middle of the file, characters in the file are overwritten with the new data.If any error has occurred during writing in the file, the stream is placed in an error state.Syntax of write methodostream& write(const char*, int);AlgorithmBegin Create a structure Student to declare variables. ... Read More
1K+ Views
This is an simple way to read an entire file into std::string in C++AlgorithmBegin Take the filename as inputstream. Declare a string variable str. Read the file till the end by using rdbuf(). Put the data into st. Print the data. End.Example Code#include #include #include #include using namespace std; int main() { ifstream f("a.txt"); string str; if(f) { ostringstream ss; ss
54K+ Views
WritingTo write a binary file in C++ use write() method. It is used to write a given number of bytes on the given stream, starting at the position of the "put" pointer. The file is extended if the put pointer is currently at the end of the file. If this pointer points into the middle of the file, characters in the file are overwritten with the new data.If any error has occurred during writing in the file, the stream is placed in an error state.Syntax of write methodostream& write(const char*, int);ReadingTo read a binary file in C++ use read() method. ... Read More
11K+ Views
Let us consider the following C++ sample code to get the list of files in a directory.AlgorithmBegin Declare a poniter dr to the DIR type. Declare another pointer en of the dirent structure. Call opendir() function to open all file in present directory. Initialize dr pointer as dr = opendir("."). If(dr) while ((en = readdir(dr)) != NULL) print all the file name using en->d_name. call closedir() function to close the directory. End.Example#include #include #include using namespace std; int main(void) { DIR ... Read More