-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathad.c
More file actions
44 lines (38 loc) · 980 Bytes
/
ad.c
File metadata and controls
44 lines (38 loc) · 980 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
43
44
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include<string.h>
#include<stdlib.h>
typedef struct login{ //user deatils
char username[100];
char password[100];
char type;
long long int accno;
char active;
}admin;
typedef struct seq{ //for generating account number
long long int count;
}acc_num;
int main(){
// setup admin
int fd = open("login.dat", O_CREAT | O_WRONLY,0766);
admin a = {"himanshu","himanshu123",'A','1','y'};
write(fd,&a,sizeof(a));
close(fd);
// set initial account num
fd = open("acc_num", O_CREAT | O_WRONLY,0766);
//fd = open("acc_num",O_RDWR);
acc_num num;
//read(fd,&num,sizeof(num));
long long int x = 100000;
num.count = x;
lseek(fd,0,SEEK_SET);
write(fd,&num,sizeof(num));
//printf("%lld",x);
close(fd);
return 0;
}