I couldn't solve it alone

Hi everybody,

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]);

a++;

}

system("pause");
}
Last edited on
Up asking for your help
let us ignore the design issues in your pogram for the moment:

what do you mean by " skipping too long lines" ?

A string should be able to hold 2 billion characters.

what does these long lines look like??
One example is line consists of 1147 arabic characters.
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.

Thanks again
Topic archived. No new replies allowed.