Dynamic SensorData Allocation

#include <iostream>
using namespace std;

// Write your struct and dynamic allocation code here
typedef struct{
   int x;
   int y;
   int z;
} SensorData;



int main() {
    int x, y, z;
    cin >> x >> y >> z;

    SensorData sensorOBJ;

    SensorData *s = new SensorData(sensorOBJ);
    s->x = x;
    s->y = y;
    s->z = z;

    cout << s->x << " " << s->y << " " << s->z;

    return 0;
}

Solving Approach

 

 

 

 

 

 

Upvote
Downvote
Loading...

Input

3 4 5

Expected Output

3 4 5