Hello programmers. I would like the below program to initialize the struct below at runtime and then display the values entered.
I have two functions as:
EnterDetails () -----------this should take the values entered and initialize the struct.
PrintEnteredDetails () ---------should display the details entered .
At first i wrote an overloaded constructor (you can ignore this constructor or advise appropriately) to initialize the struct but when it failed i decided to write the EnterDetails () function.
The problem is, the program does not display the entered values.
Kindly correct my mistakes.
The following is the program:
#include <iostream>
#include <string>
using namespace std;
{ // i doubt whether this function is initializing the struct above ----may there is problem here
//function to instantiate the struct using values passed at runtime
Somehow I don't understand your logic at all. Why don't you store the input in main in your struct and pass it to PrintEnteredDetails ?
1 2 3 4 5 6 7 8 9 10
int main()
{
LandDetails input;
cout<<"Welcome to the new lands management information system\n\n";
cout<<"Enter Surname: ";
getline (cin,input.Surname);
// get the other fields as well
PrintEnteredDetails(input);
}