Skip to content

Instantly share code, notes, and snippets.

@horvathgyozo
Last active November 29, 2016 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horvathgyozo/0f7e8f849a62c95e2ee03130e33e314d to your computer and use it in GitHub Desktop.
Save horvathgyozo/0f7e8f849a62c95e2ee03130e33e314d to your computer and use it in GitHub Desktop.
Könyvtáros példa beolvasása
#include <iostream>
using namespace std;
const int MAXN = 100;
typedef struct {
string szerzo, cim;
int db, kdb;
} Konyv;
void beolvasas(int &n, Konyv k[MAXN+1]) {
string sv;
cin >> n;
getline(cin, sv);
for (int i = 1; i<=n; i++) {
getline(cin, k[i].szerzo, ';');
getline(cin, k[i].cim, ';');
cin >> k[i].db; cin.ignore(1, ';');
cin >> k[i].kdb;
getline(cin, sv);
}
}
int main()
{
int n;
Konyv k[MAXN+1];
beolvasas(n, k);
//ellenőrző kiírás
for (int i = 1; i<=n; i++) {
cout << k[i].szerzo << " " << k[i].cim << " " << k[i].db << " " << k[i].kdb << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment