How does this not work? (structures)
Hi folks,
I'm pretty new to C++ and I tried to write a little something, just to try out my newly aqquired skills- But somehow it doesnt work and I dont quiet get the error-messages. Could somebody please have a look at this?
best wishes Alekij
Code:
#include <iostream>
using namespace std;
struct data
{
int id;
int age;
int phone;
}
void print(data)
{
cout<<"ID: " <<data.id <<"\n" <<"Age: " <<data.age << "\n" <<"Phone: " <<data.phone;
}
int main()
{
data alex;
alex.id = 1;
alex.age = 23;
alex.phone = 123456;
data tesa;
tesa.id = 2;
tesa.age = 26;
tesa.phone = 234567;
cout<<"Bitte geben sie eine Person ein.\n" <<"1 Alex\n" <<"2 Tesa\n";
int input;
switch(input)
{
case 1:
print(alex);
break;
case 2:
print(tesa);
break;
}
cin.get();
}