본문내용
---------------메인함수종료*/
void error(char *message)
{
fprintf(stderr, "%s\n", message);
exit(1);
}
void init(headerlist *list)
{
list->length = 0;
list->head = list->tail = NULL;
}
void printuser(userlist *node)
{
printf("%s%s\n",node->username, node->address);
}
void search(headerlist *list)
{
int i;
userlist *slist=list->head;
char find[size];
scanf("%s",find);
for(i=1;ilength+1;i++)
{
if(strcmp(slist->username,find)==0)
{
scanf("%s %s", slist->username, slist->address);
}
slist=slist->link;
}
}
void usernumber(headerlist *list)
{
userlist *node=list->head;
int i;
if(list->length != 0)
{
for(i=1;ilength+1;i++)
{
printuser(node);
node=node->link;
}
}
}
void adduser(headerlist *list)
{
userlist *new_node = (userlist *)malloc(sizeof(userlist));
if(new_node == NULL)
error("메모리할당실패");
if(list->tail == NULL){
list->head = list->tail = new_node;
new_node->link = new_node->link2 = new_node;
}
else{
new_node->link2 = list->tail;
list->tail->link = new_node;
list->tail = new_node;
list->head->link2 = new_node;
new_node->link=list->head;
}
list->length++;
scanf("%s %s",&new_node->username, &new_node->address);
}
void deletenode(headerlist *list, userlist *node)
{
if(list->length == 1)
init(list);
else if(node == list->head) {
list->head = node->link;
node->link->link2 = node->link2;
list->tail->link = node->link;
}
else if(node == list->tail) {
list->tail = node->link2;
node->link2->link = list->head;
list->head->link2 = list->tail;
}
else {
node->link2->link = node->link;
node->link->link2 = node->link2;
}
free(node);
list->length--;
}
void eraseuser(headerlist *list)
{
int i;
userlist *slist=list->head;
char find[size];
scanf("%s",find);
for(i=1;ilength+1;i++)
{
if(strcmp(slist->username,find)==0)
{
deletenode(list, slist);
break;
}
slist=slist->link;
}
}
void error(char *message)
{
fprintf(stderr, "%s\n", message);
exit(1);
}
void init(headerlist *list)
{
list->length = 0;
list->head = list->tail = NULL;
}
void printuser(userlist *node)
{
printf("%s%s\n",node->username, node->address);
}
void search(headerlist *list)
{
int i;
userlist *slist=list->head;
char find[size];
scanf("%s",find);
for(i=1;i
{
if(strcmp(slist->username,find)==0)
{
scanf("%s %s", slist->username, slist->address);
}
slist=slist->link;
}
}
void usernumber(headerlist *list)
{
userlist *node=list->head;
int i;
if(list->length != 0)
{
for(i=1;i
{
printuser(node);
node=node->link;
}
}
}
void adduser(headerlist *list)
{
userlist *new_node = (userlist *)malloc(sizeof(userlist));
if(new_node == NULL)
error("메모리할당실패");
if(list->tail == NULL){
list->head = list->tail = new_node;
new_node->link = new_node->link2 = new_node;
}
else{
new_node->link2 = list->tail;
list->tail->link = new_node;
list->tail = new_node;
list->head->link2 = new_node;
new_node->link=list->head;
}
list->length++;
scanf("%s %s",&new_node->username, &new_node->address);
}
void deletenode(headerlist *list, userlist *node)
{
if(list->length == 1)
init(list);
else if(node == list->head) {
list->head = node->link;
node->link->link2 = node->link2;
list->tail->link = node->link;
}
else if(node == list->tail) {
list->tail = node->link2;
node->link2->link = list->head;
list->head->link2 = list->tail;
}
else {
node->link2->link = node->link;
node->link->link2 = node->link2;
}
free(node);
list->length--;
}
void eraseuser(headerlist *list)
{
int i;
userlist *slist=list->head;
char find[size];
scanf("%s",find);
for(i=1;i
{
if(strcmp(slist->username,find)==0)
{
deletenode(list, slist);
break;
}
slist=slist->link;
}
}
추천자료
- 리눅스(proc)파일
- FIFO를 이용한 time client-server programming
- 트리(tree)관련 프로그래밍 소스 모음 (C언어)
- cyclic prefix에 대한 C언어 소스분석
- [C++]C언어를 이용한 계산기 소스 및 실행파일
- 라이프니치 수열
- 사칙연산 프로그램 -C소스,C코드
- Crout 법,Crout, C언어 소스 Crout법입니다.
- 이산수학 8장 연습문제 및 프로그래밍
- [API][C언어][소스]테트리스!
- 진수변환 C 프로그램 소스코드
- 몬티 홀 문제
- MFC 벌레 잡기 게임 (BugCatch)
- OS (운영체제) 과목 메시지 큐 구현 소스 및 결과 보고서 (c언어)
소개글