Dynamic SensorData Allocation

#include <iostream>
using namespace std;

typedef struct {
    int x;
    int y;
    int z;
} SensorData_t;

SensorData_t* pointer = new SensorData_t;

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

    pointer->x = x;
    pointer->y = y;
    pointer->z = z;

    cout << pointer->x << ' ' << pointer->y << ' ' << pointer->z << endl;

    delete pointer;
    pointer = nullptr;

    return 0;
}

Solving Approach

 

 

 

 

 

 

Upvote
Downvote
Loading...

Input

3 4 5

Expected Output

3 4 5