I have a problem, the data is transferred to the array, but not as much as I would like.
In general, I will describe my "path" and what I want to achieve. In the file P1Am.txt are data
1043.928480752930 1023.487233880130 1014.657596748670 1132.028858770790 1012.557090294320 1006.203887562610 1041.219702992490 1032.005532206760 1113.350002788500 1203.141773433670 980.619915778275 1061.732090096410 1129.337311152790 and then so exactly 128 elements. I am quite normally laying out the elements in the variable obm-> stor-> AMP [k], but for some reason that number 1043.928480752930 turns into 1043, this rounding does not suit me.
// test FILE *fid=fopen("P1Am.txt","rt"); if(fid) { float val=0; for(int k=0; k<128; k++) { fscanf(fid,"%f",&val); for(int n=0; n<obm->stor->NT; n++) { obm->stor->AMP[k*obm->stor->NT+n] = val; qDebug() << k+1 << obm->stor->AMP[k]; } } fclose(fid); } Even when I changed, on another one, the result was the same, or even worse.
// test FILE *fid=fopen("P1Am.txt","rt"); if(fid) { double val=0; for(int k=0; k<128; k++) { fscanf(fid,"%.12d",&val); for(int n=0; n<obm->stor->NT; n++) { obm->stor->AMP[k*obm->stor->NT+n] = val; // амп я тогда тоже на double менял qDebug() << k+1 << obm->stor->AMP[k]; } } fclose(fid); } The result was the same.
Here I tried this option, the result is very upset (((sadness (((
// test FILE *fid=fopen("P1Am.txt","rt"); if(fid) { double val=0; for(int k=0; k<128; k++) { fscanf(fid,"%d",&val); obm->stor->AMP1[k] = val; // создал новую перемен для теста AMP1 qDebug() << k+1 << obm->stor->AMP1[k]; } fclose(fid); } result:
1 5.1531e-321 2 5.1531e-321 3 5.1531e-321 4 5.1531e-321 5 5.1531e-321 6 5.1531e-321 7 5.1531e-321 8 5.1531e-321 9 5.1531e-321 10 5.1531e-321 11 5.1531e-321 What am I doing wrong ??
qt? Only because ofqDebug? Then, you can use QFile instead ofFILE- gil9red