Nishtha Thakur has Published 498 Articles

Pointers, smart pointers and shared pointers in C++

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

5K+ Views

PointersPointers are used to store the address of variable.SyntaxType *pointer;InitializationType *pointer; Pointer = variable name;Functionspointers are used to store address of variable.pointers can have a null value assigned.pointer can be referenced by pass by reference.a pointer has its own memory address and size on the stack.Example Live Demo#include using namespace ... Read More

Concatenate fields in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

365 Views

To concatenate fields, use the $concat operator. Let us first create a collection with documents −>db.concatenateFieldsDemo.insertOne({"StudentFirstName":"Adam", "StudentLastName":"Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6ebf46d78f205348bc62e") } >db.concatenateFieldsDemo.insertOne({"StudentFirstName":"John", "StudentLastName":"Doe"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6ebfc6d78f205348bc62f") } >db.concatenateFieldsDemo.insertOne({"StudentFirstName":"David", "StudentLastName":"Miller"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6ec376d78f205348bc630") ... Read More

How to find datatype of all the fields in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

4K+ Views

Use typeof to find datatype of all the fields −typeof db.yourCollectionName.findOne().yourFieldName;Let us first create a collection with documents −> db.findDataTypeDemo.insertOne({"ClientName":"Chris", "isMarried":false}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccf2064dceb9a92e6aa1952") }Following is the query to display all documents from a collection with the help of find() method −> db.findDataTypeDemo.findOne();This will ... Read More

getopt() function in C to parse command line arguments

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

9K+ Views

The getopt() is one of the built-in C function that are used for taking the command line options. The syntax of this function is like below −getopt(int argc, char *const argv[], const char *optstring)The opstring is a list of characters. Each of them representing a single character option.This function returns ... Read More

How to find Segmentation Error in C & C++ ? (Using GDB)

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

1K+ Views

The segmentation error is one of the runtime error, that is caused because of the memory access violation, like accessing invalid array index, pointing some restricted address etc. In this article, we will see how to detect this type of error using the GDB tool.Let us see the code and ... Read More

How to prepend string to entire column in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

202 Views

Prepend string to entire column in MongoDB using aggregate framework. Let us first create a collection with documents −> db.prependDemo.insertOne({"StudentFirstName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccf3bcedceb9a92e6aa1955") } > db.prependDemo.insertOne({"StudentFirstName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccf3bd3dceb9a92e6aa1956") } > db.prependDemo.insertOne({"StudentFirstName":"Robert"}); {    "acknowledged" : true,   ... Read More

Rint(), rintf(), rintl() in C++

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

180 Views

Here we will see three functions. These functions are Rint(), rintf() and the rintl(). These functions are used to convert floating point values into rounded format.The rint() FunctionThis function is used for rounding floating point value to integer. The syntax is like below. If the result is outside of return ... Read More

How to start an Android activity when use clicks on Notification?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

228 Views

This example demonstrate about How to start an Android activity when use clicks on NotificationStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.   ... Read More

Decrement only a single value in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

821 Views

Let us first create a collection with documents −>db.decrementingOperationDemo.insertOne({"ProductName":"Product-1", "ProductPrice":756}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7a8ae6d78f205348bc63c") } >db.decrementingOperationDemo.insertOne({"ProductName":"Product-2", "ProductPrice":890}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7a8b86d78f205348bc63d") } >db.decrementingOperationDemo.insertOne({"ProductName":"Product-3", "ProductPrice":994}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7a8c66d78f205348bc63e") } >db.decrementingOperationDemo.insertOne({"ProductName":"Product-4", "ProductPrice":1000}); {    "acknowledged" : ... Read More

Generalized Lambda Expressions in C++14

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

304 Views

In C++11, the lambda was introduced. Lambdas are basically a part of code, that can be nested inside other function call statements. By combining lambda expressions with the auto keyword, they can be used later.In C++14, these lambda expressions are improved. Here we can get the generalized lambda. For example, ... Read More

Advertisements