Je dispose d'un fichier avec trois colonnes par exemple:Lecture en nombre à partir d'un fichier dans un tableau
1 1 750
Ce sont x, y, les valeurs d'intensité. Puis j'essaye de lire dans ce fichier long en tableaux. Voici le code à ce jour:
using std::cout;
using std::endl;
using std::string;
string fOutFileName("gaintest.root");
int main()
{
std::ifstream file1("data_p30.dat");
double intensity;
int i;
int j ;
double c[1000][1000];
if (file1.is_open()) {
file1.seekg(0);
while (!file1.eof()) {
file1 >> i >> j >> intensity;
c[i][j]=intensity;
cout<<c[i][j]<<'/n';
}
file1.close();
} else cout << "Error, cannot open file 1";
}
En fin de compte, je veux être en mesure d'avoir un tableau 2D qui est liée à l'intensité. Des idées sur pourquoi j'échoue? Il compile très bien mais quand il fonctionne, il ressemble à ceci:
root [0]
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x0000003701098c05 in waitpid() from /lib64/libc.so.6
#1 0x000000370103c481 in do_system() from /lib64/libc.so.6
#2 0x00002b036f5ebc6a in TUnixSystem::StackTrace()()
from /batchsoft/root/root528-x86_64-slc5-43/lib/libCore.so
#3 0x00002b036f5eb63c in TUnixSystem::DispatchSignals(ESignals)()
from /batchsoft/root/root528-x86_64-slc5-43/lib/libCore.so
#4 <signal handler called>
#5 0x00002b0370acd515 in TRint::Run(bool)()
from /batchsoft/root/root528-x86_64-slc5-43/lib/libRint.so
#6 0x000000000040106d in main()
===========================================================
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5 0x00002b0370acd515 in TRint::Run(bool)()
from /batchsoft/root/root528-x86_64-slc5-43/lib/libRint.so
#6 0x000000000040106d in main()
===========================================================
utilisent un type de matrice réelle plutôt que 'doubles [] []' comme ceux fournis par uBLAS boost et NT2 – 111111
'deux c [ 1000,1000]; 'C++ est valide, mais il ne fait absolument pas ce que vous pensez. – us2012
L'erreur pourrait ne pas avoir de sens pour * vous * mais ce serait très utile pour nous. – alestanis