开发者

Reading a large text file to memory in C++

开发者 https://www.devze.com 2022-12-31 12:21 出处:网络
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 tr

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

精彩评论

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

关注公众号