I am trying to initializing structs in the following manner below, and then passing it by reference and then trying to retrieve the value. However, i get a random numbers back, which seems to suggest i dont have anything in that address. Why is this happening?
#include <iostream>
using namespace std;
struct newStruct {
int numberOne;
int numberTwo;
int numberThree;
};
newStruct initializer{
1,2,3
};
void printStruct(struct newStruct* inputNew) {
printf("This is the output %d\n", inputNew->numberOne );
printf("This is the second output %d\n", inputNew->numberTwo);
printf("This is the third output %d\n", inputNew->numberThree);
}
int main() {
struct newStruct initializer;
printStruct(&initializer);
getchar();
}