我正在从文件中提取数据(theta.txt')
,使用ifstream
.
std::ifstream theta_extracter("theta.txt", std::ifstream::in);
std::string line;
std::vector <double> thetas;
/* For each line in file until EOF */
while (true){
getline(theta_extracter, line); /* Get line */
if (theta_extracter.eof()) break; /* Stop at EOF*/
std::stringstream stream(line); /* Parse Line */
std::string exported;
/*Parse line*/
while (true){
stream >> exported;
thetas.push_back(atof(exported.c_str())); /* Store value*/
if (stream.eof()) break;
}
}
theta_extracter.close();
如果我不关闭theta_extracter
,我会收到一条巨大的错误消息:
*** glibc detected *** ./combi: free(): invalid next size (fast): 0x0000000000b69ba0 ***
======= Backtrace: =========
/lib64/libc.so.6[0x36c98760e6]
/lib64/libc.so.6[0x36c9878c13]
./combi[0x405964]
./combi[0x4042ca]
./combi[0x402e95]
./combi[0x40266f]
./combi[0x401e19]
./combi[0x401471]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x36c981ecdd]
./combi[0x4012c9]
======= Memory map: ========
00400000-0040d000 r-xp 00000000 00:2a 59351995 /nfs/stak/students/m/moissinb/WORKSPACE/EXP3/VCG Solver/combi
0060c000-0060d000 rw-p 0000c000 00:2a 59351995 /nfs/stak/students/m/moissinb/WORKSPACE/EXP3/VCG Solver/combi
00b5f000-00c4a000 rw-p 00000000 00:00 0 [heap]
36c9400000-36c9420000 r-xp 00000000 fd:00 2613 /lib64/ld-2.12.so
36c961f000-36c9620000 r--p 0001f000 fd:00 2613 /lib64/ld-2.12.so
36c9620000-36c9621000 rw-p 00020000 fd:00 2613 /lib64/ld-2.12.so
36c9621000-36c9622000 rw-p 00000000 00:00 0
36c9800000-36c998a000 r-xp 00000000 fd:00 5271 /lib64/libc-2.12.so
36c998a000-36c9b89000 ---p 0018a000 fd:00 5271 /lib64/libc-2.12.so
36c9b89000-36c9b8d000 r--p 00189000 fd:00 5271 /lib64/libc-2.12.so
36c9b8d000-36c9b8e000 rw-p 0018d000 fd:00 5271 /lib64/libc-2.12.so
36c9b8e000-36c9b93000 rw-p 00000000 00:00 0
36c9c00000-36c9c83000 r-xp 00000000 fd:00 5272 /lib64/libm-2.12.so
36c9c83000-36c9e82000 ---p 00083000 fd:00 5272 /lib64/libm-2.12.so
36c9e82000-36c9e83000 r--p 00082000 fd:00 5272 /lib64/libm-2.12.so
36c9e83000-36c9e84000 rw-p 00083000 fd:00 5272 /lib64/libm-2.12.so
36cfc00000-36cfc16000 r-xp 00000000 fd:00 5275 /lib64/libgcc_s-4.4.7-20120601.so.1
36cfc16000-36cfe15000 ---p 00016000 fd:00 5275 /lib64/libgcc_s-4.4.7-20120601.so.1
36cfe15000-36cfe16000 rw-p 00015000 fd:00 5275 /lib64/libgcc_s-4.4.7-20120601.so.1
36d0400000-36d04e8000 r-xp 00000000 fd:03 548265 /usr/lib64/libstdc++.so.6.0.13
36d04e8000-36d06e8000 ---p 000e8000 fd:03 548265 /usr/lib64/libstdc++.so.6.0.13
36d06e8000-36d06ef000 r--p 000e8000 fd:03 548265 /usr/lib64/libstdc++.so.6.0.13
36d06ef000-36d06f1000 rw-p 000ef000 fd:03 548265 /usr/lib64/libstdc++.so.6.0.13
36d06f1000-36d0706000 rw-p 00000000 00:00 0
7fc067c6a000-7fc067c6f000 rw-p 00000000 00:00 0
7fc067c96000-7fc067c99000 rw-p 00000000 00:00 0
7fff52f65000-7fff52f7a000 rw-p 00000000 00:00 0 [stack]
7fff52fff000-7fff53000000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Abort (core dumped)
如果我关闭它,它会在那时出现故障。
关于出了什么问题的任何想法?