🔒 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
  • 302
    Views
  • 2
    Participants
Last reply from:
Haruka Aya

Trending Topics

Online now

Members online
1,055
Guests online
3,422
Total visitors
4,477

Forum statistics

Threads
2,354,158
Posts
29,382,473
Members
1,079,351
Latest member
JKDELUNA
Back
Top