<div dir="ltr">Hola Joaquín,<br><div class="gmail_extra"><br></div><div class="gmail_extra">Como parece que quieres guardar todo el contenido del fichero, entonces creo que la forma más fácil es hacer eso mismo.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Puedes usar un canal de caracteres, 'stringstream', para copiar datos de un canal a otro; por ejemplo,</div><div class="gmail_extra"><br></div><div class="gmail_extra">ostringstream oss;</div><div class="gmail_extra"><br></div><div class="gmail_extra">file.get( *oss.rdbuf() );  // Lee y copia todos los caracteres del fichero al canal de caracteres</div><div class="gmail_extra"><br></div><div class="gmail_extra">linea = oss.str();  // Copiamos la cadena interna del canal a nuestra cadena, 'linea'</div><div class="gmail_extra"><br></div><div class="gmail_extra">Aquí, los caracteres de fin-de-línea se guardarán en la cadena.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Otra solución se basa en agregar cadenas para ir acumulando. Usa dos cadenas: una temporal para leer cada línea y otra que acumula; por ejemplo,</div><div class="gmail_extra"><br></div><div class="gmail_extra">string strTotal( "" );</div><div class="gmail_extra"><br></div><div class="gmail_extra">while( getline(file, linea) )<br></div><div class="gmail_extra">  strTotal += linea;  // Agregamos el contenido de 'linea' al final de 'strTotal'</div><div class="gmail_extra"><br></div><div class="gmail_extra">También puedes optar por invocar 'append()' en lugar de usar el operador sobrecargado de +=.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Espero que esto te ayude.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Steven</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-05 12:43 GMT-05:00 Joaquin Copello <span dir="ltr"><<a href="mailto:joaquin.lpda20@hotmail.com" target="_blank">joaquin.lpda20@hotmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">




<div dir="ltr">
<div style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255)">
<p>Buenas gente lo hago simple y rapido para ver si me pueden ayudar. Tengo este codigo:</p>
<p><span></span></p>
<pre style="font-family:monospace"><ol><li style="font-weight:normal;vertical-align:top"><div style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1em;line-height:1.2em;font-family:monospace;margin:0px;padding:0px;vertical-align:top;background:none"><span style="color:rgb(51,153,0)">#include <fstream></span></div></li><li style="font-weight:normal;vertical-align:top"><div style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1em;line-height:1.2em;font-family:monospace;margin:0px;padding:0px;vertical-align:top;background:none"><span style="color:rgb(51,153,0)">#include <string></span></div></li><li style="font-weight:normal;vertical-align:top"><div style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1em;line-height:1.2em;font-family:monospace;margin:0px;padding:0px;vertical-align:top;background:none"> </div></li><li style="font-weight:normal;vertical-align:top"><div style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1em;line-height:1.2em;font-family:monospace;margin:0px;padding:0px;vertical-align:top;background:none"><span style="color:rgb(0,0,255)">int</span> main<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span> </div></li><li style="font-weight:normal;vertical-align:top"><div style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1em;line-height:1.2em;font-family:monospace;margin:0px;padding:0px;vertical-align:top;background:none"><span style="color:rgb(0,128,0)">{</span> </div></li><li style="font-weight:normal;vertical-align:top"><div style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1em;line-height:1.2em;font-family:monospace;margin:0px;padding:0px;vertical-align:top;background:none">    std<span style="color:rgb(0,128,128)">::</span><span style="color:rgb(0,119,136)">ifstream</span> file<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(255,0,0)">"NomFichero.txt"</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span></div></li><li style="font-weight:normal;vertical-align:top"><div style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1em;line-height:1.2em;font-family:monospace;margin:0px;padding:0px;vertical-align:top;background:none">    std<span style="color:rgb(0,128,128)">::</span><span style="color:rgb(0,119,136)">string</span> linea<span style="color:rgb(0,128,128)">;</span> </div></li><li style="font-weight:normal;vertical-align:top"><div style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1em;line-height:1.2em;font-family:monospace;margin:0px;padding:0px;vertical-align:top;background:none">    <span style="color:rgb(0,0,255)">while</span> <span style="color:rgb(0,128,0)">(</span>std<span style="color:rgb(0,128,128)">::</span><span style="color:rgb(0,119,136)">getline</span><span style="color:rgb(0,128,0)">(</span>file, linea<span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,0)">)</span></div></li><li style="font-weight:normal;vertical-align:top"><div style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1em;line-height:1.2em;font-family:monospace;margin:0px;padding:0px;vertical-align:top;background:none"><span style="color:rgb(0,128,0)">}</span></div></li></ol><p>Como puedo hacer para que linea no guarde solo lo ultimo que lee si no que</p><p>lea una linea y guarde lea otra y guarde y asi sucesivamente. Gracias<br></p></pre></div></div></blockquote><div><br></div></div></div></div>