1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
int ReadLokum(void)
{
int iVal_1, iVal_2;
int ret = 0;
int i = 1;
int j = 1;
FILE * infile;
char buf[12];
char temp_name[1000];
strcpy_s(temp_name, cRunLocation);
_itoa_s(CurrentSet, buf, 10);
strcat_s(temp_name, "Lokum_");
strcat_s(temp_name, buf);
strcat_s(temp_name, ".csv");
errno_t err;
err = fopen_s(&infile, temp_name, "r");
if (infile == NULL)
{ LogFile << "Error reading file Lokum_.csv" << endl;
exit(2); }
else
LogFile << "Successfully opened file Lokum_.csv" << endl;
char chrX[1000];
fgets(chrX, sizeof(chrX) - 1, infile); //Skip past header
while (1)
{
for (i = 0; i <= 360; i++)
{
ret = fscanf_s(infile, "%d,%d,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
&iVal_1,
&iVal_2,
&LokumFIXED[j][i],
&LokumRate5[j][i],
&LokumUST7[j][i],
&LokumBeta[j][i],
&LokumUS[j][i],
&LokumAGGR[j][i],
&LokumSMALL[j][i],
&LokumINTL[j][i],
&LokumMONEY[j][i]);
if (ret == EOF) break;
}
if (ret == EOF) break;
j++;
if (j > LastScenario) return 0; // Exit to save time
}
fclose(infile);
return 0;
}
|