#include #include #include int main(void) { struct HistoryHeader { int version; // версия базы char copyright[64]; // копирайт char symbol[12]; // инструмент int period; // период инструмента int digits; // число знаков после запятой в инструменте time_t timesign; // временной отпечаток создания базы time_t last_sync; // время последней синхронизации int unused[13]; // для будущего использования }HstrHdr; #pragma pack(push,1) //---- standard representation of the quote in the database struct RateInfo { double open; double low; double high; double close; double vol; time_t ctm; // current time in seconds }; #pragma pack(pop) FILE *fp; int count,elnum; struct RateInfo rate; printf("sizeof(struct HistoryHeader) %d\n",sizeof(struct HistoryHeader)); printf("sizeof(struct RateInfo) %d\n",sizeof(struct RateInfo)); if((fp=fopen("C:\\Program Files\\MetaTrader - Alpari\\history\\Alpari-Demo\\EURUSD1440.hst","rb"))==NULL) { printf("Error opening file!\n"); return; } if(fp) { count=fread(&HstrHdr,sizeof(struct HistoryHeader),1,fp); count=fread(&rate,sizeof(struct RateInfo),1,fp); if(ferror(fp)) { perror("Error file reading!\n"); exit(1); } } fclose(fp); printf("the last synchronization time: %s\n",ctime(&(HstrHdr.last_sync))); printf("timesign of the database creation: %s\n",ctime(&(HstrHdr.timesign))); printf("quote open: %f\n",rate.open); printf("quote high: %f\n",rate.high); printf("quote low: %f\n",rate.low); printf("quote close: %f\n",rate.close); printf("quote volume: %f\n",rate.vol); printf("quote time: %s\n",ctime(&(rate.ctm))); return 0; }