½ÃÀÛÆäÀÌÁö·Î Áñ°Üã±âÃß°¡
·Î±×ÀÎ
ȸ¿ø°¡ÀÔ l Ã⼮üũ l ¸¶ÀÌÆäÀÌÁö l CGIMALL
ÀÚ·á½Ç »çÀÌÆ®µî·Ï ·©Å·100 ÇÁ·Î±×·¥¸®ºä °ü¸®ÀÚÃßõÀÚ·á Ãʺ¸°¡À̵å
Ä¿¹Â´ÏƼ
Àüü ÆîÃ帱â
Äü¸Þ´º¸µÅ© jquery , CSS , PHP , Javascript , ¹«·áÆùÆ® , ASP
»ó¼¼°Ë»ö
Ȩ > Ä¿¹Â´ÏƼ > Áú¹®°ú´äº¯ »ó¼¼º¸±â
Ä¿¹Â´ÏƼ ±¸Àα¸Á÷
»çÀÌÆ®µî·Ï
Ŭ¶ó¿ìµåű×
javascript
PHP
ASP
CSS
mysql
html
jquery
������
image
mobile
API
slide
°Ô½ÃÆÇ
ÇöÀçÁ¢¼ÓÀÚ ¸í »õ·Î°íħ
°Ô½ÃÆÇŸÀÌƲ Áú¹®°ú´äº¯ / »ó¼¼º¸±â
Æ®À§ÅÍ·Î º¸³»±â
Ãßõ¼ö 87 | Á¶È¸¼ö 830 | µî·ÏÀÏ 2001-07-29 17:13:41
display
");
  printf("-------------------------------------------------\n");

  while(head1)
  {
 
  printf("%d",i++);
printf("  ID : %s\n",head1->person.ID);
printf("  Email address : %s\n",head1->person.email);
printf("  Department : %s\n\n",head1->person.dept);
    head1=head1->rare;
  }
    printf("--------------------------------------------\n");
    printf("displayed : %d\n",i-1);

    if(!head)
    {
      printf("--------------------------------------------\n");
    }
}


main()

{
struct nodedata person;
NODE *tnode;
char sel,ch;
int j;

FILE *fp;

head=NULL;
P_Node=NULL;

tnode=malloc(sizeof(NODE));
tnode->pre=NULL;
tnode->rare=NULL;

printf("Content-type: text/html\n\n");
printf("");
printf("Add, display, save output");
printf("");
printf("

Addressbook

");


if((fp=fopen("data.dat","r")) == NULL)
{
printf(" no input data.
");
exit(1);
}


while(1)
  {
  if((fread(&tnode->person,sizeof(struct nodedata),1,fp))!=1)  break;

if(head==NULL)
{
  head=tnode;
P_Node=tnode;
}

else
{
tnode->pre=P_Node;

P_Node->rare=tnode;
P_Node=tnode;
P_Node->rare=NULL;
}

tnode=malloc(sizeof(NODE));




/*    P_Node->rare=tnode;
      tnode->pre=P_Node;
      tnode->rare=NULL;*/


  }fclose(fp);

 
switch(sel)
{

case '1':
add();
ch=getchar();fflush(stdin);
break;


case '2':
display();
getchar(); fflush(stdin);
break;


case '3':
save();

dafault:

}   


printf(" ID : %s
",person.ID);
printf(" Email : %s
",person.email);
printf(" Department : %s
",person.dept);
printf("");
printf("");

} /* main end */

´Ð³×ÀÓ

accord

À̸ÞÀÏ

junyong72@yahoo.com

Á¦¸ñ

Ãâ·Â, º¯¼ö¿¡ °üÇÑ Áú¹®
³»¿ë
C ·Î CGI ¸¦ Â¥°í Àִµ¥ Àß ¾ÈµÇ¼­ Áú¹®µå¸³´Ï´Ù.
ÁÖ¼Ò·Ï ÇÁ·Î±×·¥À¸·Î data.dat È­ÀÏÀ» Àоî¿Í¼­
»ç¶÷À» Ãß°¡, display, save ÇØ¾ß µÇ´Âµ¥
º¯¼ö¸¦ CGI ¿¡¼­ ¸ø Àд °Å °°°í
main function ¿¡ ÀÖ´Â printf ¸¸ Ç¥ÇöÇϴµ¥
³ª¸ÓÁö function ¿¡ ÀÖ´Â °Íµµ Ç¥ÇöÇÏ°í ½Í½À´Ï´Ù.
µµ¿ÍÁÖ¼¼¿ä.


#include
#include
#include

void add();
void display();
void save();


struct nodedata

{
char ID[10];
char email[25];
char dept[8];
} person;

struct node

{
struct nodedata person;
struct node *pre;
struct node *rare;
};


typedef struct node NODE;

NODE *head,*head1;
NODE *P_Node;





void add()
{
  struct node *tnode;

  tnode=malloc(sizeof(NODE));

  if (P_Node==NULL)
  {
tnode->person=person;
P_Node=tnode;
P_Node->pre=NULL;
P_Node->rare=NULL;
  }

  else
  {
P_Node->rare=tnode;
tnode->pre=P_Node;
tnode->rare=NULL;
P_Node=tnode;
P_Node->person=person;
  }

  if(head==NULL) head=P_Node;

}


void save()
{
FILE *fp;
head1=head;

if((fp=fopen("data.dat","r")) == NULL)

{

exit(1);
}

while(head1)
{
  if((fwrite(&head1->person,sizeof(struct nodedata),1,fp))!=1) break;
head1=head1->rare;
}
fclose(fp);
exit(1);
}



void display()
{
  int i=1;

  head1=head;

  printf("
Ãßõ½ºÅ©·¦¼Ò½ºº¸±â ¸ñ·Ï
ÀÌÀü°Ô½Ã±Û ÀÌ·± ¸Þ¼¼Áö°¡ ¶ß³×¿© ¤Ñ.¤Ñ 2001-07-29 03:16:22
´ÙÀ½°Ô½Ã±Û ±¸ÀÎ/±¸Á÷ »õº½·Î ¼³Ä¡Áß¿¡ ¿¡·¯°¡ ³µ¾î¿° 2001-08-01 21:43:20