本篇紀錄如何從程式的segmentation fault,配合dmesg 和addr2line 來除錯,查出程式是掛(死)在哪個原始碼的第幾行。 首先先來寫一個會讓程式崩潰的 ... ... <看更多>
「linux程式記憶體區段錯誤」的推薦目錄:
- 關於linux程式記憶體區段錯誤 在 [問題] 程式記憶體區段錯誤? - 看板C_and_CPP 的評價
- 關於linux程式記憶體區段錯誤 在 程式segmentation fault後, 用dmesg和addr2line來除錯 的評價
- 關於linux程式記憶體區段錯誤 在 biosig python3 - Segmentation fault (core dumped) - Stack ... 的評價
- 關於linux程式記憶體區段錯誤 在 ValveSoftware/steam-for-linux - Segmentation fault, line 756 的評價
- 關於linux程式記憶體區段錯誤 在 [問題] 關於core dumped - Mo PTT 鄉公所 的評價
linux程式記憶體區段錯誤 在 biosig python3 - Segmentation fault (core dumped) - Stack ... 的推薦與評價
... <看更多>
相關內容
linux程式記憶體區段錯誤 在 ValveSoftware/steam-for-linux - Segmentation fault, line 756 的推薦與評價
[SOLVED] [Steam Client] Crashing at startup - Segmentation fault, line 756 - Arch Linux #4340. Closed. SALVOuankeBALDO opened this issue on Feb ... ... <看更多>
linux程式記憶體區段錯誤 在 [問題] 關於core dumped - Mo PTT 鄉公所 的推薦與評價
xxxxx 時程式跑到一半就出現'程式記憶體區段錯誤(core dumped)' 請問各位神人 ... 推Tetralet:現在很多Linux Dist 都把core dump 關掉了 03/14 14:02. ... <看更多>
linux程式記憶體區段錯誤 在 [問題] 程式記憶體區段錯誤? - 看板C_and_CPP 的推薦與評價
小弟是用Linux寫程式
編譯器是g++
我只是寫了一個讀檔的程式要存data至陣列
編譯也都沒問題
可是執行 ./a.out 以後卻會出現
"程式記憶體區段錯誤"
請問這是什麼意思
不好意思 我不確定這是程式的問題還是Linux的問題
code
----
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main()
{
ifstream inFile( "data.dat", ios::in );
if ( !inFile ){
cerr<<"File could not be opened"<<endl;
exit( 1 );
}
ofstream outFile( "3Ddata.dat", ios::out );
if ( !outFile ){
cerr<<"File could not be opened"<<endl;
exit( 1 );
}
double x;
double y;
double z;
double vx;
double vy;
double vz;
int counter = 0;
double xyz[180][180][180]={0};
while ( inFile >> x >> y >> z >> vx >> vy >> vz ){
counter = counter+1;
int xgrid = 90+x/0.04;
int ygrid = 90+y/0.04;
int zgrid = 90+z/0.04;
if(xgrid>=0 && ygrid>=0 && zgrid>=0 && xgrid<180 && ygrid<180 &&
zgrid<180){
xyz[xgrid][ygrid][zgrid] = xyz[xgrid][ygrid][zgrid]+1.0;
}
cout<< counter <<endl;
}
int i,j,k;
for(i=0; i<180; i++){
for(j=0; j<180; j++){
for(k=0; k<180; k++){
xyz[i][j][k]= xyz[i][j][k]*(1.29e+8)/(0.04*0.04*0.04);
outFile<<(i-90)*0.04+0.02<<" "<<(j-90)*0.04+0.02<<" "<<(k-90)*0.04+
0.02<< " "<<xyz[i][j][k]<<endl;
}
}
}
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.4.235
貼了
※ 編輯: peter74123 來自: 140.112.4.235 (08/31 20:16)
... <看更多>
相關內容