🔒 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.

About this Thread

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

Trending Topics

Online now

Members online
359
Guests online
2,844
Total visitors
3,203

Forum statistics

Threads
2,331,966
Posts
29,261,430
Members
1,147,928
Latest member
kalilinux
Back
Top