🔒 Closed C++ pointers

Status
Not open for further replies.

Welcome Guest

Established
Mga master programmer, ask ko lang paano ko po ma pa run ang code na to, same output po sana. Kailangan daw tanggalin lahat ng asterisks ( * ) tapos gamitan nlng daw ng typedef int* IntPtr;

Code:
#include <iostream>
using namespace std;

int main()
{
    int *p1, *p2;

    p1 = new int;
    *p1 = 42;
    p2 = p1;

    cout << "*p1 == " << *p1 << endl;
    cout << "*p2 == " << *p2 << endl;
    *p2 = 53;
    cout << "*p1 == " << *p1 << endl;
    cout << "*p2 == " << *p2 << endl;
    p1 = new int;
    *p1 = 88;
    cout << "*p1 == " << *p1 << endl;
    cout << "*p2 == " << *p2 << endl;


   return 0;
}
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 1
    Replies
  • 274
    Views
  • 2
    Participants
Last reply from:
Haruka Aya

Online now

Members online
508
Guests online
1,286
Total visitors
1,794

Forum statistics

Threads
2,277,853
Posts
28,979,277
Members
1,229,112
Latest member
rosearugay
Back
Top