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

Trending Topics

Online now

Members online
655
Guests online
1,544
Total visitors
2,199

Forum statistics

Threads
2,293,501
Posts
29,084,467
Members
1,208,823
Latest member
Qqqqc11
Back
Top