Перенос столбцов из txt в матрицу на с++
txt файл такого вида :
0.0000 0.0000 0.0000 0.0000 1.0000
5.3144 -1.2879 -0.0772 0.0187 0.9968
5.3562 -1.2006 -0.0813 0.0182 0.9965
число строк несколько тысяч или десятков тысяч.
использую microsoft visual c++ 2010 экспресс
Использую такой код, но если значения не целые, то выводит огромные отрицательные числа
Код:
#include <iostream>
#include <fstream>
int main()
{
std::ifstream in("input2.txt");
if (in == 0)
{
std::cout << "Error! File not found!" << std::endl;
system("pause");
return 1;
}
float size_x, size_y;
in >> size_x;
in >> size_y;
int** arr = new int*[size_x];
for (int i = 0; i < size_x; i++)
{
arr[i] = new int[size_x];
}
for (int i = 0; i < size_x; i++)
{
for (int j = 0; j < size_y; j++)
{
in >> arr[i][j];
}
}
std::cout << "size = " << size_x << std::endl;
std::cout << "size = " << size_y << std::endl;
for (int i = 0; i < size_x; i++)
{
for (int j = 0; j < size_y; j++)
{
std::cout << arr[i][j] << " ";
}
std::cout << std::endl;
}
system("pause");
return 0;
}
#include <fstream>
int main()
{
std::ifstream in("input2.txt");
if (in == 0)
{
std::cout << "Error! File not found!" << std::endl;
system("pause");
return 1;
}
float size_x, size_y;
in >> size_x;
in >> size_y;
int** arr = new int*[size_x];
for (int i = 0; i < size_x; i++)
{
arr[i] = new int[size_x];
}
for (int i = 0; i < size_x; i++)
{
for (int j = 0; j < size_y; j++)
{
in >> arr[i][j];
}
}
std::cout << "size = " << size_x << std::endl;
std::cout << "size = " << size_y << std::endl;
for (int i = 0; i < size_x; i++)
{
for (int j = 0; j < size_y; j++)
{
std::cout << arr[i][j] << " ";
}
std::cout << std::endl;
}
system("pause");
return 0;
}
а должно быть наоборот int size_x, size_y; и float ** arr = new float *[size_x];, так как оператор >> перегружен для соответствующих типов. А если размеры массива записаны в файле, то они должны быть в форме целых чисел (без точек и запятых).
5 3
0.0000 0.0000 0.0000 0.0000 1.0000
5.3144 -1.2879 -0.0772 0.0187 0.9968
5.3562 -1.2006 -0.0813 0.0182 0.9965
Я хочу что бы из txt файла результаты записались в dll, в data[1]...data[6] (вместо x, y...). Как можно объединить 2 кода?
Код:
#include <windows.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#pragma warning ( disable : 4996 ) // functions like strcpy are now deprecated for security reasons
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data);
int __declspec(dllexport) APIENTRY UserParamNames(char *data);
#define PI 3.14159265358979323846
BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data)
{
data[1] = x;
data[2] = y;
data[3] = z;
data[4] = l;
data[5] = m;
data[6] = n;
data[7] = 1.0;
return 0;
}
int __declspec(dllexport) APIENTRY UserParamNames(char *data)
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#pragma warning ( disable : 4996 ) // functions like strcpy are now deprecated for security reasons
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data);
int __declspec(dllexport) APIENTRY UserParamNames(char *data);
#define PI 3.14159265358979323846
BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data)
{
data[1] = x;
data[2] = y;
data[3] = z;
data[4] = l;
data[5] = m;
data[6] = n;
data[7] = 1.0;
return 0;
}
int __declspec(dllexport) APIENTRY UserParamNames(char *data)
Код:
#include <windows.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#pragma warning ( disable : 4996 ) // functions like strcpy are now deprecated for security reasons
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data);
int __declspec(dllexport) APIENTRY UserParamNames(char *data);
BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data)
int main()
{
int size_x, size_y;
std::ifstream in("input2.txt");
if (in == 0)
{
std::cout << "Error! File not found!" << std::endl;
system("pause");
return 1;
}
in >> size_x;
in >> size_y;
float** arr = new float*[size_x];
for (int i = 0; i < size_x; i++)
{
arr[i] = new float[size_x];
}
for (int i = 0; i < size_x; i++)
{
for (int j = 0; j < size_y; j++)
{
in >> arr[i][j];
}
}
std::cout << "size = " << size_x << std::endl;
std::cout << "size = " << size_y << std::endl;
for (int i = 0; i < size_x; i++)
{
for (int j = 0; j < size_y; j++)
{
std::cout << arr[i][j] << " ";
data[1] = arr[i];
data[2] = arr[j];
data[3] = 0;
data[4] = 0;
data[5] = 0;
data[6] = 0;
data[7] = 1.0;
system("pause");
return 0;
}
std::cout << std::endl;
}
}
}
int __declspec(dllexport) APIENTRY UserParamNames(char *data)
{
unsigned int i;
i = (unsigned int) (unsigned char) data[0];
strcpy(data,"");
return 0;
}
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#pragma warning ( disable : 4996 ) // functions like strcpy are now deprecated for security reasons
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data);
int __declspec(dllexport) APIENTRY UserParamNames(char *data);
BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data)
int main()
{
int size_x, size_y;
std::ifstream in("input2.txt");
if (in == 0)
{
std::cout << "Error! File not found!" << std::endl;
system("pause");
return 1;
}
in >> size_x;
in >> size_y;
float** arr = new float*[size_x];
for (int i = 0; i < size_x; i++)
{
arr[i] = new float[size_x];
}
for (int i = 0; i < size_x; i++)
{
for (int j = 0; j < size_y; j++)
{
in >> arr[i][j];
}
}
std::cout << "size = " << size_x << std::endl;
std::cout << "size = " << size_y << std::endl;
for (int i = 0; i < size_x; i++)
{
for (int j = 0; j < size_y; j++)
{
std::cout << arr[i][j] << " ";
data[1] = arr[i];
data[2] = arr[j];
data[3] = 0;
data[4] = 0;
data[5] = 0;
data[6] = 0;
data[7] = 1.0;
system("pause");
return 0;
}
std::cout << std::endl;
}
}
}
int __declspec(dllexport) APIENTRY UserParamNames(char *data)
{
unsigned int i;
i = (unsigned int) (unsigned char) data[0];
strcpy(data,"");
return 0;
}
Ну а массив data где объявлен? Он должен быть объявлен в той же области видимости, в которой он будет использоваться.
я ориентировался на этот код. тут нету объявления, поэтому подумал что можно так же сделать.
Код:
#include <windows.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#pragma warning ( disable : 4996 ) // functions like strcpy are now deprecated for security reasons
/*
Written by Kenneth E. Moore
Complete re-write August 11, 2004 to fix the model for r
Added more robust bracket search July 22, 2008
*/
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data);
int __declspec(dllexport) APIENTRY UserParamNames(char *data);
#define PI 3.14159265358979323846
BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}
/*
For the call to UserSourceDefinition, the data is stored as follows:
ndata = the number of elements in the array data
data[0] = the total number of values in the passed data array
data[1] = x (to be computed by the dll and returned)
data[2] = y (to be computed by the dll and returned)
data[3] = z (to be computed by the dll and returned)
data[4] = l (to be computed by the dll and returned)
data[5] = m (to be computed by the dll and returned)
data[6] = n (to be computed by the dll and returned)
data[7] = relative intensity (to be computed by the dll and returned)
data[20] = wavelength in µm
data[21] = millimeters per unit length (1.0 for mm, 25.4 for inches, 10.0 for cm and 1000.0 for meters)
data[22] = a random number seed
data[30] = parameter 1 from user input
data[31] = parameter 2 from user input
etc... up to data[maxdata] where maxdata = int(data[0])
The DLL must compute data 1 through 7 given the other data,
and return 0 if it works; else return -1
*/
/*
This DLL models a flat disk source which has an na which
depends upon the radial aperture.
The ray starting point is chosen from a distribution of the form
I(r) = A + B r^2 + C r^4
where 0 <= r <= R.
Once the ray starting position is determined, the ray angles fall
within a cone of angle given by
NA(r) = D + E r^2 + F r^4
within this cone, the ray distribution is uniform.
*/
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data)
{
int loop;
double R, A, B, C, D, E, F, P;
double R2, R4;
double r2, r4;
double x, y, z, l, m, n, lmr, r, g, p, t, ot;
double costhetam, random_number, random_angle;
double na, theta_m;
double r_lo, r_hi, g_lo, g_hi;
srand((DWORD)data[22]);
R = data[30];
A = data[31];
B = data[32];
C = data[33];
D = data[34];
E = data[35];
F = data[36];
/* integrate the distribution over a circle */
R2 = R*R;
R4 = R2*R2;
P = (A/2.0 + B*R2/4.0 + C*R4/6.0)*R2;
/* normalize to 1 */
if (P <= 0.0)
{
r = 0.0;
goto jump_here_if_r_is_zero;
}
else
{
A /= P;
B /= P;
C /= P;
}
/* pick a random number between 0 and 1 */
p = (double)rand()/(double)RAND_MAX;
/* find r that yields this p. We can't solve this directly, so use bracket search */
loop = 0;
r_lo = 0.0;
r_hi = R;
g_lo = 0.0;
g_hi = 1.0;
ot = 0.1;
// robust linear solver
while(fabs(g_hi-g_lo)>1.0E-10 && ++loop < 100)
{
t = (p - g_lo)/(g_hi-g_lo);
if (t > 0.5) t -= ot;
else t += ot;
if (loop < 10) ot *= 0.2;
r = r_lo + t*(r_hi - r_lo);
r2 = r*r;
r4 = r2*r2;
g = (A/2.0 + B*r2/4.0 + C*r4/6.0)*r2;
if (g < p)
{
r_lo = r;
g_lo = g;
}
else
{
r_hi = r;
g_hi = g;
}
}
jump_here_if_r_is_zero:;
/* okay, we have r... now pick an angle */
random_angle = 2.0*PI * (double)rand()/(double)RAND_MAX;
x = r*cos(random_angle);
y = r*sin(random_angle);
z = 0.0;
/* at this aperture, what is the NA? */
r2 = r*r;
r4 = r2*r2;
na = D + E*r2 + F*r4;
if (na < 0.0) na = 0.0;
if (na > 1.0) na = 1.0;
/* now choose the ray cosines */
theta_m = asin(na);
costhetam = cos(theta_m);
random_number = (double)rand()/(double)RAND_MAX;
n = 1.0 - random_number*(1.0 - costhetam);
random_number = (double)rand()/(double)RAND_MAX;
random_angle = 2.0*PI*random_number;
lmr = sqrt(1.0 - n*n);
l = lmr * cos(random_angle);
m = lmr * sin(random_angle);
data[1] = x;
data[2] = y;
data[3] = z;
data[4] = l;
data[5] = m;
data[6] = n;
data[7] = 1.0;
return 0;
}
/*For the call to UserSourceDefinition, the data is stored as follows:
data[0] is an integer indicating the number of the parameter whose name should be returned by the function.*/
int __declspec(dllexport) APIENTRY UserParamNames(char *data)
{
/* this function returns the name of the parameter requested */
unsigned int i;
i = (unsigned int) (unsigned char) data[0];
strcpy(data,"");
if (i == 1) strcpy(data,"R");
if (i == 2) strcpy(data,"A");
if (i == 3) strcpy(data,"B");
if (i == 4) strcpy(data,"C");
if (i == 5) strcpy(data,"D");
if (i == 6) strcpy(data,"E");
if (i == 7) strcpy(data,"F");
return 0;
}
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#pragma warning ( disable : 4996 ) // functions like strcpy are now deprecated for security reasons
/*
Written by Kenneth E. Moore
Complete re-write August 11, 2004 to fix the model for r
Added more robust bracket search July 22, 2008
*/
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data);
int __declspec(dllexport) APIENTRY UserParamNames(char *data);
#define PI 3.14159265358979323846
BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}
/*
For the call to UserSourceDefinition, the data is stored as follows:
ndata = the number of elements in the array data
data[0] = the total number of values in the passed data array
data[1] = x (to be computed by the dll and returned)
data[2] = y (to be computed by the dll and returned)
data[3] = z (to be computed by the dll and returned)
data[4] = l (to be computed by the dll and returned)
data[5] = m (to be computed by the dll and returned)
data[6] = n (to be computed by the dll and returned)
data[7] = relative intensity (to be computed by the dll and returned)
data[20] = wavelength in µm
data[21] = millimeters per unit length (1.0 for mm, 25.4 for inches, 10.0 for cm and 1000.0 for meters)
data[22] = a random number seed
data[30] = parameter 1 from user input
data[31] = parameter 2 from user input
etc... up to data[maxdata] where maxdata = int(data[0])
The DLL must compute data 1 through 7 given the other data,
and return 0 if it works; else return -1
*/
/*
This DLL models a flat disk source which has an na which
depends upon the radial aperture.
The ray starting point is chosen from a distribution of the form
I(r) = A + B r^2 + C r^4
where 0 <= r <= R.
Once the ray starting position is determined, the ray angles fall
within a cone of angle given by
NA(r) = D + E r^2 + F r^4
within this cone, the ray distribution is uniform.
*/
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data)
{
int loop;
double R, A, B, C, D, E, F, P;
double R2, R4;
double r2, r4;
double x, y, z, l, m, n, lmr, r, g, p, t, ot;
double costhetam, random_number, random_angle;
double na, theta_m;
double r_lo, r_hi, g_lo, g_hi;
srand((DWORD)data[22]);
R = data[30];
A = data[31];
B = data[32];
C = data[33];
D = data[34];
E = data[35];
F = data[36];
/* integrate the distribution over a circle */
R2 = R*R;
R4 = R2*R2;
P = (A/2.0 + B*R2/4.0 + C*R4/6.0)*R2;
/* normalize to 1 */
if (P <= 0.0)
{
r = 0.0;
goto jump_here_if_r_is_zero;
}
else
{
A /= P;
B /= P;
C /= P;
}
/* pick a random number between 0 and 1 */
p = (double)rand()/(double)RAND_MAX;
/* find r that yields this p. We can't solve this directly, so use bracket search */
loop = 0;
r_lo = 0.0;
r_hi = R;
g_lo = 0.0;
g_hi = 1.0;
ot = 0.1;
// robust linear solver
while(fabs(g_hi-g_lo)>1.0E-10 && ++loop < 100)
{
t = (p - g_lo)/(g_hi-g_lo);
if (t > 0.5) t -= ot;
else t += ot;
if (loop < 10) ot *= 0.2;
r = r_lo + t*(r_hi - r_lo);
r2 = r*r;
r4 = r2*r2;
g = (A/2.0 + B*r2/4.0 + C*r4/6.0)*r2;
if (g < p)
{
r_lo = r;
g_lo = g;
}
else
{
r_hi = r;
g_hi = g;
}
}
jump_here_if_r_is_zero:;
/* okay, we have r... now pick an angle */
random_angle = 2.0*PI * (double)rand()/(double)RAND_MAX;
x = r*cos(random_angle);
y = r*sin(random_angle);
z = 0.0;
/* at this aperture, what is the NA? */
r2 = r*r;
r4 = r2*r2;
na = D + E*r2 + F*r4;
if (na < 0.0) na = 0.0;
if (na > 1.0) na = 1.0;
/* now choose the ray cosines */
theta_m = asin(na);
costhetam = cos(theta_m);
random_number = (double)rand()/(double)RAND_MAX;
n = 1.0 - random_number*(1.0 - costhetam);
random_number = (double)rand()/(double)RAND_MAX;
random_angle = 2.0*PI*random_number;
lmr = sqrt(1.0 - n*n);
l = lmr * cos(random_angle);
m = lmr * sin(random_angle);
data[1] = x;
data[2] = y;
data[3] = z;
data[4] = l;
data[5] = m;
data[6] = n;
data[7] = 1.0;
return 0;
}
/*For the call to UserSourceDefinition, the data is stored as follows:
data[0] is an integer indicating the number of the parameter whose name should be returned by the function.*/
int __declspec(dllexport) APIENTRY UserParamNames(char *data)
{
/* this function returns the name of the parameter requested */
unsigned int i;
i = (unsigned int) (unsigned char) data[0];
strcpy(data,"");
if (i == 1) strcpy(data,"R");
if (i == 2) strcpy(data,"A");
if (i == 3) strcpy(data,"B");
if (i == 4) strcpy(data,"C");
if (i == 5) strcpy(data,"D");
if (i == 6) strcpy(data,"E");
if (i == 7) strcpy(data,"F");
return 0;
}
Код:
#include <windows.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#pragma warning ( disable : 4996 ) // functions like strcpy are now deprecated for security reasons
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data);
int __declspec(dllexport) APIENTRY UserParamNames(char *data);
#define PI 3.14159265358979323846
BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved){
return TRUE;
}
//--------------
/*
Структура текстового файла input2.txt:
------------
0.4566
1.5666
2.0002
7.9856
0.7845
1.0041
------------
это те 6 чисел, которые надо записать в data[1] ... data[6]
*/
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data)
{
std::ifstream in("input2.txt");
if (in == 0){
std::cout << "Error! File not found!" << std::endl;
system("pause");
return 1;
}
for (int i = 1; i < 7; i++){
in >> data[i];
std::cout << data[i] << std::endl;
}
data[7] = 1.0;
return 0;
}
//--------------
int __declspec(dllexport) APIENTRY UserParamNames(char *data){
unsigned int i;
i = (unsigned int) (unsigned char) data[0];
strcpy(data,"");
return 0;
}
//--------------
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#pragma warning ( disable : 4996 ) // functions like strcpy are now deprecated for security reasons
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data);
int __declspec(dllexport) APIENTRY UserParamNames(char *data);
#define PI 3.14159265358979323846
BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved){
return TRUE;
}
//--------------
/*
Структура текстового файла input2.txt:
------------
0.4566
1.5666
2.0002
7.9856
0.7845
1.0041
------------
это те 6 чисел, которые надо записать в data[1] ... data[6]
*/
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data)
{
std::ifstream in("input2.txt");
if (in == 0){
std::cout << "Error! File not found!" << std::endl;
system("pause");
return 1;
}
for (int i = 1; i < 7; i++){
in >> data[i];
std::cout << data[i] << std::endl;
}
data[7] = 1.0;
return 0;
}
//--------------
int __declspec(dllexport) APIENTRY UserParamNames(char *data){
unsigned int i;
i = (unsigned int) (unsigned char) data[0];
strcpy(data,"");
return 0;
}
//--------------
В этом комментарии подробно расписана структура data
Код:
/*
For the call to UserSourceDefinition, the data is stored as follows:
ndata = the number of elements in the array data
data[0] = the total number of values in the passed data array
data[1] = x (to be computed by the dll and returned)
data[2] = y (to be computed by the dll and returned)
data[3] = z (to be computed by the dll and returned)
data[4] = l (to be computed by the dll and returned)
data[5] = m (to be computed by the dll and returned)
data[6] = n (to be computed by the dll and returned)
data[7] = relative intensity (to be computed by the dll and returned)
data[20] = wavelength in µm
data[21] = millimeters per unit length (1.0 for mm, 25.4 for inches, 10.0 for cm and 1000.0 for meters)
data[22] = a random number seed
data[30] = parameter 1 from user input
data[31] = parameter 2 from user input
etc... up to data[maxdata] where maxdata = int(data[0])
The DLL must compute data 1 through 7 given the other data,
and return 0 if it works; else return -1
*/
For the call to UserSourceDefinition, the data is stored as follows:
ndata = the number of elements in the array data
data[0] = the total number of values in the passed data array
data[1] = x (to be computed by the dll and returned)
data[2] = y (to be computed by the dll and returned)
data[3] = z (to be computed by the dll and returned)
data[4] = l (to be computed by the dll and returned)
data[5] = m (to be computed by the dll and returned)
data[6] = n (to be computed by the dll and returned)
data[7] = relative intensity (to be computed by the dll and returned)
data[20] = wavelength in µm
data[21] = millimeters per unit length (1.0 for mm, 25.4 for inches, 10.0 for cm and 1000.0 for meters)
data[22] = a random number seed
data[30] = parameter 1 from user input
data[31] = parameter 2 from user input
etc... up to data[maxdata] where maxdata = int(data[0])
The DLL must compute data 1 through 7 given the other data,
and return 0 if it works; else return -1
*/
Цитата: Meander
Мне не вполне очевидна логика того, что ты хочешь сделать. Какие данные, откуда и куда, в каком количестве надо перезаписывать? В пользовательских функциях UserSourceDefinition и UserParamNames, предполагается, что массив данных одномерный, почему тогда в текстовом файле хранится целая таблица чисел? Ты хотел записать данные в data[1] ... data[6], это только 6 чисел, зачем в текстовом файле несколько тысяч значений? В комментарии из последнего присланного кода ясно, что пользовательские данные должны содержаться начиная с data[30].
Я хочу написать dll для получения дополнительной функции в программе. data[1]-[6] это координаты и ориентация в угловых координатах для одного объекта, мне нужно расположить тысячи объектов в пространстве. Координаты объектов содержаться в виде таблицы в txt файле - 6 столбцов и тысячи строк (или 5 т.к. одна всегда равна 0).
data[1] = x (to be computed by the dll and returned)
data[2] = y (to be computed by the dll and returned)
data[3] = z (to be computed by the dll and returned)
data[4] = l (to be computed by the dll and returned)
data[5] = m (to be computed by the dll and returned)
data[6] = n (to be computed by the dll and returned)
data[2] = y (to be computed by the dll and returned)
data[3] = z (to be computed by the dll and returned)
data[4] = l (to be computed by the dll and returned)
data[5] = m (to be computed by the dll and returned)
data[6] = n (to be computed by the dll and returned)
с data[30] начинаются данные которые можно изменять в программе для которой нужна dll, но поскольку планируется только вывод координат из файла они незадействуются. Извиняюсь за отсутствие объяснений.
Получилось хоть один байт записать?
На данный момент нет. Попробовал запустить Ваш код. К сожалению выяснилось, что программа не воспринимает с++, а только си...
Так там только функцию чтения из файла и записи блока данных на сишные поменять.