I was making a little thing, just learning some stuff, and I came up with this...
Code:#include <iostream> #include <string> using namespace std; struct datacore { int id_number; int age; int securitycode; }; int main() { string name; datacore bob,charlie,george; bob.id_number = 338; bob.age = 27; bob.securitycode=1229; charlie.id_number = 890; charlie.age = 39; charlie.securitycode=8894; george.id_number = 115; george.age = 70; george.securitycode = 1126; cout<<"Enter an employee name to access information about them"; cin>>name; cin.ignore(); cout<<[name].id_number<<"\n"<<[name].age<<"\n"<<[name].securitycode; cin.get(); return 1; }
I wanted it to index whatever name was entered and use that id_number,age, and securitycode. But It doesn't work, it just gives an error, it is just calling it a parse error. So how do you index a string?



LinkBack URL
About LinkBacks



. Check out the book Thinking in C++ by Bruce Eckel (google it) it is a free book and will teach you a lot.