-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain2.cpp
More file actions
35 lines (29 loc) · 983 Bytes
/
Copy pathmain2.cpp
File metadata and controls
35 lines (29 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "MyMenuBoard.h"
#include <fcntl.h>
#include <iostream>
#include <list>
#include <string>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
int main() {
// StudentList.dat 파일을 읽기
MenuBoard std;
char *pathname = (char *)"./MenuBoardList.dat";
list<MenuBoard> StudentList;
list<MenuBoard>::iterator it;
int fd = open(pathname, O_RDONLY); //.dat파일 오픈
struct stat fileInfo;
fstat(fd, &fileInfo);
for (int i = 0; i < fileInfo.st_size / sizeof(MenuBoard); i++) {
// FIFO방식으로 Menu 정보를 자료구조에 대입
read(fd, &std, sizeof(MenuBoard));
StudentList.push_back(std);
}
cout << "[Menu]\t[Score]\t[Price]" << endl;
for (it = StudentList.begin(); it != StudentList.end(); it++) {
cout << it->getName() << "\t " << it->getoption() << "\t "
<< it->getprice() << endl;
}
printf(" ---show %ld menu---\n", StudentList.size());
}