开发者

Reading a large text file to memory in C++

Is there a way to read a large text file (~60MB) into memory at once (like a compiler flag to increase program memory limit) ? Currently, ofstream's open function throws a segmentation fault while trying to read this file.

ifstream fis;
fis.open("my_large_file.txt"); // Segfaults here

The fil开发者_如何学编程e just consists of rows of the form

number_1<tabspace>number_2

i.e., two numbers separated by a tabspace.


You have some other problem, because you aren't reading the file by just calling open. My guess is the file doesn't exist (or doesn't exist in the relative path you think it should exist in).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜