Anvi Jain

Anvi Jain

427 Articles Published

Articles by Anvi Jain

Page 31 of 43

How to get current location provider information in android?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 610 Views

This example demonstrate about How to get current location provider information in android.Step 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.     In the above code, we have taken a text view to show the current network location provider.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.Manifest; import android.content.pm.PackageManager; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.location.LocationManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; ...

Read More

Compile 32-bit program on 64-bit gcc in C and C++

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 1K+ Views

Nowadays the compiler comes with default 64-bit version. Sometimes we need to compile and execute a code into some 32bit system. In that time, we have to use thisS feature.At first, we Shave to check the current target version of the gcc compiler. To check this, we have to type this command.gcc –v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu ........... ........... ...........Here it is showing that Target is x86_64. So we are using the 64-bit version of gcc. Now to use the 32-bit system, we have to write the following command.gcc –m32 program_name.cSometimes this command may generate ...

Read More

How to get duplicate records from Android sqlite?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 679 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to get duplicate records from Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ...

Read More

Type difference of character literals in C vs C++

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 220 Views

In C++ the size of the character constants is char. In C the type of character constant is integer (int). So in C the sizeof(‘a’) is 4 for 32bit architecture, and CHAR_BIT is 8. But the sizeof(char) is one byte for both C and C++.Example#include main() {    printf("%d", sizeof('a')); }Output4Example#include using namespace std; main(){    cout

Read More

C++ set for user define data type

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 953 Views

Here we will see how we can make a set for user defined datatypes. The Set is present in C++ STL. This is a special type of data structure, it can store data in sorted order, and does not support duplicate entry. We can use set for any type of data, but here we will see how we can also use set for userdefined datatypes.To use user-defined datatypes into stack, we have to override < operator, that can compare two values of that type. If this is not present, it cannot compare two objects, so the set cannot store data ...

Read More

Constructor Delegation in C++

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 1K+ Views

Here we will see what is the constructor delegation? When a constructor calls other constructor of the same class, then it is called the constructor delegation. This feature is present from C++11.Let us see the following program, and try to analyze what are the difficulties in this code.Example#include using namespace std; class MyClass {    int a, b, c;    public:    MyClass(){       a = b = c = 0;    }    MyClass(int c) {       // Initializing a and b are redundent, only c initialization is needed here       a = 0;       b = 0;       this->c = c;    }    void display(){       cout

Read More

lrint() and llrint() in C++

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 185 Views

In this section we will see the lrint() and llring() in C++. At first let us discuss about the lrint().The lrint() function is used to round the fractional given value in the argument to an integral value using current rounding mode. The current mode is determined by using fesetround().>=This lrint() function takes the double or float or integer value as input parameter, and returns the long int value by rounding the fractional part into an integral part.Example#include #include #include using namespace std; main() {    int x = 40;    long int res;    fesetround(FE_DOWNWARD); // setting ...

Read More

Check the current number of connections to MongoDB?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 871 Views

You can check the current number of connections to MongoDB with the help of the following syntax −var anyVariableName= db.serverStatus(); yourVariableName.connections;The second syntax is as follows −db.serverStatus().connections;To understand both the above syntaxes, let us see them one by one −Case 1 − The first query is as follows −> var checkCurrentNumberOfConnections = db.serverStatus() > checkCurrentNumberOfConnections.connections;The following is the output −{ "current" : 1, "available" : 999999, "totalCreated" : 1 }Case 2 − The second query is as follows −> db.serverStatus().connectionsThe following is the output −{ "current" : 1, "available" : 999999, "totalCreated" : 1 }

Read More

Check privileges (grants) for a specific user in MySQL?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 615 Views

If you want to check privileges for a specific user, then use the below syntax −SHOW GRANTS FOR 'yourUserName'@'yourHostName';The above syntax will check privileges for a specific user.To check the privileges for a specific user, then use FOR. Let’s say we have a username ‘JOHN‘ and host is ‘%’. Following is the query to get the privileges for user “JOHN” −mysql> SHOW GRANTS FOR 'JOHN'@'%';This will produce the following output −+--------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- --------------+ | Grants for JOHN@% | +--------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- --------------+ | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, ...

Read More

How to use cast() in Android sqlite?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 480 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use cast() in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create ...

Read More
Showing 301–310 of 427 articles
« Prev 1 29 30 31 32 33 43 Next »
Advertisements