cod


cod

#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> struct user{ #define START_ID 10000000 int id; char pwd[25]; }; int main(int argc, char *argv[]){ int fd; struct user log; if((fd=open(argv[1],O_RDWR|O_CREAT,0640))==-1){ perror(argv[1]); exit(2); } printf("ID와 비밀번호를 입력하세요\n"); printf("%-9s %-8s \n","아이디","비밀번호"); while(scanf("%d %s",&log.id,&log.pwd)==2){ lseek(fd,(log.id-START_ID)*sizeof(log),SEEK_SET); write(fd,&log,sizeof(log)); } close(fd); exit(0); }...



원문링크 : cod