hi i am new to VC++ ,i want to read a .txt file and parse line by line and interpret the data on windows console ,can any one help me in this regard plz..
thanks in advance
Jump to PostI would do it like this:
std::ifstream fin(Filename.c_str()); if(fin == NULL) std::cout << "Cannot open file." << std::endl; std::vector<std::string> Lines; std::string line; while(getline(fin, line)) { Lines.push_back(line); } for(unsigned int i = 0; i < Lines.size(); i++) { std::cout << Lines[i] << std::endl; }
Dave
I would do it like this:
std::ifstream fin(Filename.c_str());
if(fin == NULL)
std::cout << "Cannot open file." << std::endl;
std::vector<std::string> Lines;
std::string line;
while(getline(fin, line))
{
Lines.push_back(line);
}
for(unsigned int i = 0; i < Lines.size(); i++)
{
std::cout << Lines[i] << std::endl;
}
Dave
hi Davidoria can you send the C code for the same (to read the each line from .txt file and to interpret the data on the windows console "table format ")
Sorry, I only work with c++ - I believe there is a separate subforum for c programming.
Dave
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.