What is the use of `%p` in printf in C?

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

9K+ Views

In C we have seen different format specifiers. Here we will see another format specifier called %p. This is used to print the pointer type data. Let us see the example to get a better idea.Example#include main() {    int x = 50;    int *ptr = &x;    printf("The address is: %p, the value is %d", ptr, *ptr); }OutputThe address is: 000000000022FE44, the value is 50

C++ Program to Perform Finite State Automaton based Search

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

588 Views

This is a C++ program to perform finite state automaton based search. An automaton with a finite number of states is called a Finite Automaton. Here, a text is given text[0 … t-1] and a pattern p[0 ... p-1] is also given. We have to find the pattern in the text and print its all occurrences at the respective indices.AlgorithmsBegin    Function void transitiontable():    1) put the entries in first row and filled it up. All entries in first row are always 0 except the entry for p[0] character. Always we need to go to state 1.    for ... Read More

How to create notifications that do not go away when clicked in Android?

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

56 Views

This example demonstrate about How to start an activity when user clicks a notification in AndroidStep 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.     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Context ; import android.content.Intent ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; public class MainActivity extends AppCompatActivity {   ... Read More

How to create timer using C++11?

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

1K+ Views

Here we will see how to make timer using C++. Here we are creating one class called later. This class has following properties.int (milliseconds to wait until to run code)bool (If this is true, it returns instantly, and run the code after specified time on another thread)The variable arguments (exactly we want to feed to std::bind)We can change the chrono::milliseconds to nanoseconds or microseconds etc. to change the precision.Example Code#include #include #include #include class later {    public:       template       later(int after, bool async, callable&& f, arguments&&... args){     ... Read More

How to create a nested JSplitPane in Java?

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

169 Views

Let us first create three components −JComponent one = new JLabel("Label One"); one.setBorder(BorderFactory.createLineBorder(Color.yellow)); JComponent two = new JLabel("Label Two"); two.setBorder(BorderFactory.createLineBorder(Color.orange)); JComponent three = new JLabel("Label Three"); three.setBorder(BorderFactory.createLineBorder(Color.blue));Now, we will split one and two components.JSplitPane split1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, one, two); split1.setDividerLocation(0.5); split1.setDividerSize(2);After that the above splitted pane would be splitted with component three making the process nested −JSplitPane split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, split1, three ); split2.setDividerLocation(0.9); split2.setDividerSize(2);The following is an example to create nested JSplitPane −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JSplitPane; public class SwingDemo {    public static void main(String[] ... Read More

How do I split a numerical query result in MySQL?

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

88 Views

To split a numerical query result, you can use the CONCAT() function in MySQL. Let us first create a table −mysql> create table DemoTable    (    StudentId int    ); Query OK, 0 rows affected (0.68 sec)Now you can insert some records in the table using insert command −mysql> insert into DemoTable values(2222); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(5555); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(4567); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(8905); Query OK, 1 row affected (0.15 sec)Display all records from ... Read More

HTML target Attribute

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

548 Views

The target attribute of the element is used to set where the linked document will open. You can set the document to open in a new window, same frame, parent frame, etc.Following is the syntax −Here, _blank is used to open the linked document in new window or tab, _self opens the linked document in the same frame as it was clicked, _parent opens the document in the parent frame, _top opens the linked document in the entire body of the window, frame opens the linked document in a named frame.Let us now see an example to implement target attribute ... Read More

How to create transparent Status Bar and Navigation Bar in iOS?

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

1K+ Views

You might have come across many application where the screen extends to complete screen i.e transparent Status Bar and transparent navigation bar.Here we will be seeing how to create an application where the you’ll be having transparent status and navigation bar.So let’s get startedStep 1 − Open Xcode → New Project → Single View Application → Let’s name it “TransparentViews”Step 2 − Embed the View Controller in Navigation Controller. Add Image View and shown and add image.Step 3 − Run the application without adding any piece of code for making status and navigation bar transparent.The screen looks like belowStep 4 ... Read More

Count rows having three or more rows with a certain value in a MySQL table

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

80 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> UserId int    -> ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.09 sec) ... Read More

C++ Program for Sum of squares of first n natural numbers?

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

431 Views

In this problem we will see how we can get the sum of squares of first n natural numbers. Here we are using one for loop, that runs from 1 to n. In each step we are calculating square of the term and then add it to the sum. This program takes O(n) time to complete. But if we want to solve this in O(1) or constant time, we can use this series formula −AlgorithmsquareNNatural(n)begin    sum := 0    for i in range 1 to n, do       sum := sum + i^2    done    return ... Read More

Advertisements