I have a text file that I want to get its contents line by line, this code worked for me, but when I checked that array, I found that some lines was skipped. these are the too long lines. I expect it is something related to the string size or buffer size, but I couldn't fix it. Could any one tell me how to fix that? and what is the reason for that skipping.
# include <stdafx.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string str [6348][1];
ifstream myfile("simple.txt");
int a = 0;
int b = 0;
if(!myfile) //Always test the file open.
{
cout<<"Error opening output file"<<endl;
system("pause");
return -1;
}
while(!myfile.eof())
{
getline(myfile,str[a][b]);
Thank you, Finally it is solved.
While I was working on adding some other pieces of code to my work, I got a problem of stack overflow, and I changed the stack size to solve that issue. Now, I found that it can get all my text even the longest line.