-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.c
More file actions
43 lines (35 loc) · 1001 Bytes
/
client.c
File metadata and controls
43 lines (35 loc) · 1001 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
36
37
38
39
40
41
42
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXSIZE 27
int main()
{
int shmid1,shmid2;
key_t key1,key2;
char *type;
int *buy;
key1=5678;
key2=8765;
shmid1=shmget(key1, MAXSIZE, IPC_CREAT | 0666);
shmid2=shmget(key2, MAXSIZE, IPC_CREAT | 0666);
type=shmat(shmid1, NULL, 0);
buy=shmat(shmid2, NULL, 0);
printf("Welcome to Bluejack Smartphone\n\n");
printf(" Client\n");
printf("==============================\n\n");
do{
printf("Input your phone type [Nokia, Samsung, Apple] [\"exit\" to close this program] : ");
scanf("%s",type);
if(strcmp("exit",type) == 0){
exit(0);
};
}while(strcmp("nokia",type) != 0 && strcmp("samsung",type) != 0 && strcmp("apple",type) != 0);
do{
printf("Input how many phone you want to buy [1..8] : ");
scanf("%d",buy);
}while(*buy<1||*buy>8);
exit(0);
}