`
gauss2008
  • 浏览: 40958 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

动态链表

FP 
阅读更多
#include <stdio.h>
#include 
<malloc.h>
typedef 
struct LNode
...{
    FILE 
*fp;
    
char *fname;
    
struct LNode *next;
}
LNode;
LNode 
*LinkList;
LNode 
*ListInit(LNode *linklist)...{
    
    
if((linklist=(LNode *)malloc(sizeof(LNode)))==NULL)...{
        printf(
"Init Link Error");
        exit(
0);
    }

    linklist
->next=NULL;
    
return linklist;
}

ListInsert(LNode 
*linklist, char *fname,FILE *fp)...{
    LNode 
*lnode;
  LNode 
*p;  
  
char *test;  
  p
=linklist;
 test
=fname;
printf(
"in list insert fname=%s ",fname);
            
if((lnode=(LNode*)malloc(sizeof(LNode)))==NULL)...{
                    printf(
"Insert Error");
                    exit(
0);
                }

                
while(p->next!=NULL)...{
                    p
=p->next;                    
                    
if(!strcmp(p->fname,fname))
                        
...{
                            p
->fp=fp;
                            
return ;
                        }

                }

                p
->next=lnode;
                lnode
->fp=fp;
                lnode
->fname=fname;
                
//strcpy(lnode->fname,fname);
                lnode->next=NULL;
                p
=lnode;
                printf(
"...........test1=%s ",test);
                
//test="AAA";
                while(*test!='
 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics