title: (C++) How can I use getline() with an integer while reading a file?
body: <p>I'm trying to create some code to open a file, read the content and check if a couple of integers are equal by using getline(). The problem is that it seems to work only with strings, instead of doing it with integers aswell. Could you help me?</p>
  
  <pre><code>fstream ficheroEntrada;
  string frase;
  int dni, dnitxt;
  int i=0;
  int time;
  
  cout &lt;&lt; "Introduce tu DNI: ";
  cin &gt;&gt; dni;
  
  ficheroEntrada.open ("Datos.txt",ios::in);
  if (ficheroEntrada.is_open()) {
      while (! ficheroEntrada.eof() ) {
          getline (ficheroEntrada, dnitxt);
          if (dnitxt == dni){
              getline (ficheroEntrada, frase);
              cout &lt;&lt; dni &lt;&lt; " " &lt;&lt; frase &lt;&lt; endl;        
          }else{
              getline (ficheroEntrada, dnitxt);
          }   
      }
      ficheroEntrada.close();
  }
  </code></pre>