title: How to identify a double \n\n with fgets/read/fread
body: <p>I have a dot file, which i need to parse it into a graph structure using C.</p>
  
  <p>My dot file contains 2 blocs seperated with a double \n:</p>
  
  <ul>
  <li><p>the one is verticle</p></li>
  <li><p>the other one is edges</p></li>
  </ul>
  
  <p>I have tried with fgets since it reads until \n is met. It is helpfull to count the number of verticles but not whats comes after it. I don't have any idea of how i can do it</p>
  
  <p>Right now I have a function like this (not complete)</p>
  
  <pre class="lang-c prettyprint-override"><code>int graphe_charger_dot(graphe *g, char *nom_fichier) {
    FILE * f;
    int n;
    if ((f = fopen(nom_fichier, "r")) == 0) {
      puts(nom_fichier);
      puts("Erreur d'ouverture du fichier");
      return -1;
    }
  
    char buffer[500];
  
    fgets(buffer, sizeof(buffer),f);
  ;
    if (strcmp(buffer, "graph {\n") != 0) {
      puts("Erreur de compatibilité de fichier");
      puts(nom_fichier);
      return -1;
    }
    puts("Fichier ouvert et compatible");
    puts("Lecture du buffer 1");
  
    // reads the first verticles. the atoi is just here to test if i can convert an char to integer even with a non integer right after it. 
    fgets(buffer, sizeof(buffer),f);
    n = atoi(buffer);
    g-&gt;n += 1;
  
    return 0;
  }
  
  </code></pre>
  
  <p>My dot file</p>
  
  <pre><code>graph {
    0;
    1;
    2;
    3;
    4;
    5;
    6;
    7;
    8;
  
  
    0 -- 1;
    0 -- 4;
    0 -- 5;
    0 -- 6;
    0 -- 8;
    1 -- 2;
    1 -- 3;
    1 -- 4;
    1 -- 5;
    2 -- 3;
    2 -- 4;
    2 -- 5;
    2 -- 8;
    3 -- 7;
    5 -- 7;
    5 -- 8;
    6 -- 8;
    7 -- 8;
  }
  </code></pre>
  
  <p>and the structure of the graph</p>
  
  <pre class="lang-c prettyprint-override"><code>struct s_graphe {
    int n;                /* number of verticles */
    int m;                /* number of edges */
    int adj[GRAPHE_ORDRE_MAX][GRAPHE_ORDRE_MAX];
    /* Adjacency matrix of the graph */
  };
  </code></pre>