-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_NEW.c
53 lines (44 loc) · 1.03 KB
/
add_NEW.c
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "head.h"
void add_NEW(){
char input_title[100];
char author[100];
int price;
int stock;
char book_info[100];
int fd;
system("clear");
printf("\033[%d;%df",7, 25);
printf(" title: ");
scanf("%[^\n]s", input_title);
if(find_BOOK2(input_title, 0) == -1){
fflush(stdin);
system("clear");
printf("\033[%d;%df",7, 25);
printf("author: ");
scanf("%[^\n]s", author);
system("clear");
printf("\033[%d;%df",7, 25);
printf(" price: ");
scanf("%d", &price);
system("clear");
printf("\033[%d;%df",7, 25);
printf(" 입고량: ");
scanf("%d", &stock);
sprintf(book_info, "%s/%s/%d/0/%d", input_title, author, price, stock);
chmod("./book_list.txt",0777);
fd = open("./book_list.txt", O_WRONLY|O_CREAT,0777);
lseek(fd, 0, SEEK_END);
write(fd, "\n", 1);
write(fd, book_info, strlen(book_info));
close(fd);
printf("\n완료되었습니다");
fflush(stdout);
usleep(1000000);
}
else{
perror("이미 존재하는 책입니다!");
fflush(stdout);
usleep(1000000);
return;
}
}