0
Hello, I have a question about file reading. Well I’m starting to mess with files now, I would like to know how to read line by line a file and present these lines, already researched, but I only find explanations that mix C with C++.
0
Hello, I have a question about file reading. Well I’m starting to mess with files now, I would like to know how to read line by line a file and present these lines, already researched, but I only find explanations that mix C with C++.
0
#include <string>
#include <fstream>
#include <iostream>
std::ifstream arquivo( "teste.txt" ); # Seleciona o arquivo
std::string linha; # String linha
int main()
{
while(getline(arquivo, linha)) # Enquanto houver linhas, continuará
{
std::cout << linha << std::endl; # Imprime valores, linha a linha
}
return 0;
}
Browser other questions tagged c++
You are not signed in. Login or sign up in order to post.
What is the file format? It is a text file?
– Gustavo Luciano
If it is in C++ use the ifstream class or fstream. Search the documentation.
– anonimo
file is format . txt
– Gustavo Daniel