marooh  | bonjour,
 j'essais d'ecrire un prog qui permet d'afficher à partir de la ligne n1 n2 lignes d'un fichier texte et ceci à l'aide des chaines double chainage,le code compile et tout mais ça ne fonctionne pas or je ne trouve aucune erreur,tout parait logique       si vous pouvez m'aider voici mon code
    
  Code :
 - #include <string.h>
 - #include <stdio.h>
 - #include <stdlib.h>
 - struct dllist {
 -  char *s;
 -  struct dllist *next;
 -  struct dllist *prev;
 - };
 - struct dllist *head, *tail;
 - void append_node(struct dllist *lnode);
 - void insert_node(struct dllist *lnode, struct dllist *after);
 - void remove_node(struct dllist *lnode);
 - void ouvrir(FILE **fp);
 - void utilitaire1(char *argv[],struct dllist *lnode,int pos,int nbr);
 - int main(int argc, char **argv) {
 -  struct dllist *lnode;
 - FILE *fp;char f[100];
 - int pos,nbr;
 -  if(3>argc)
 - {printf("utilisation incorrecte!!!" );exit(0);}
 - ouvrir(&fp);
 - sscanf(argv[3],"%d",&pos);
 - sscanf(argv[4],"%d",&nbr);
 -  while(fgets(f,100,fp)) {
 -   lnode = (struct dllist *)malloc(sizeof(struct dllist));
 -   strncpy(lnode->s,f,strlen(f));
 -   append_node(lnode);
 -  }
 - fclose(fp);
 -  for(lnode = head; lnode != NULL; lnode = lnode->next) {
 -   printf("%s\n", lnode->s);
 -  }
 - if (strcmp(argv[2],"view" )==0) utilitaire1(argv,lnode,pos,nbr);
 -  while(head != NULL)
 -   remove_node(head);
 -  getchar();
 - return EXIT_SUCCESS;
 - }
 - void append_node(struct dllist *lnode) {
 -  if(head == NULL) {
 -   head = lnode;
 -   lnode->prev = NULL;
 -  } else {
 -   tail->next = lnode;
 -   lnode->prev = tail;
 -  }
 -  tail = lnode;
 -  lnode->next = NULL;
 - }
 - void insert_node(struct dllist *lnode, struct dllist *after) {
 -  lnode->next = after->next;
 -  lnode->prev = after;
 -  if(after->next != NULL)
 -   after->next->prev = lnode;
 -  else
 -   tail = lnode;
 -  after->next = lnode;
 - }
 - void remove_node(struct dllist *lnode) {
 -  if(lnode->prev == NULL)
 -   head = lnode->next;
 -  else
 -   lnode->prev->next = lnode->next;
 -  if(lnode->next == NULL)
 -   tail = lnode->prev;
 -  else
 -   lnode->next->prev = lnode->prev;
 - }
 - void utilitaire1(char *argv[],struct dllist *lnode,int pos,int nbr)
 - {int i,j;
 -    struct dllist  *courant ;
 -   for (i = 1; i < pos; ++i)
 -     courant = courant->next;
 -     if (pos == i)
 -     {
 -         for (j=i;j<nbr;++j)
 -     printf("%s\n",courant->s); }
 - }
 - void ouvrir(FILE **fp)
 - {
 - if(!(*fp=fopen("test.txt","r" )))
 - {
 - printf("le fichier est inexistant" );
 - exit(0);
 - }
 - else printf("ouverture du fichier... \n" );
 - }
 
  |  
 
     |