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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#include "DragonFireSDK.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <math.h>
#include <cstring>
#include <sstream>
using namespace std;
int info1, info2, info3;
void WriteFile(int info1, int info2, int info3);
void ReadFile();
int length;
int dataF1, dataF2, dataF3;
char data1[5];
char data2[5];
char data3[100];
stringstream ss;
string scoreS;
void WriteFile(int info1, int info2, int info3)
{
ss.clear();
ss << info1;
getline(ss, scoreS);
strcpy_s(data1, scoreS.c_str());
dataF1 = FileOpen("data1.txt"); // open file
if (dataF1 == 0){ dataF1 = FileCreate("data1.txt"); }
dataF1 = FileOpen("data1.txt");
length = strlen(data1);
FileWrite(dataF1, data1, length); //WRITE data
FileClose(dataF1); // release file
ss.clear();
ss << info2;
getline(ss, scoreS);
strcpy_s(data2, scoreS.c_str());
dataF2 = FileOpen("data2.txt"); // open file
if (dataF2 == 0){ dataF2 = FileCreate("data2.txt"); }
dataF2 = FileOpen("data2.txt");
length = strlen(data2);
FileWrite(dataF2, data2, length); //WRITE data
FileClose(dataF2); // release file
ss.clear();
ss << info3;
getline(ss, scoreS);
strcpy_s(data3, scoreS.c_str());
dataF3 = FileOpen("data3.txt"); // open file
if (dataF3 == 0){ dataF3 = FileCreate("data3.txt"); }
dataF3 = FileOpen("data3.txt");
length = strlen(data3);
FileWrite(dataF3, data3, length); //WRITE data
FileClose(dataF3); // release file
}
void ReadFile()
{
dataF1 = FileOpen("data1.txt"); // open file
if (dataF1 == 0){ dataF1 = FileCreate("data1.txt"); }
dataF1 = FileOpen("data1.txt");
length = strlen(data1);
FileRead(dataF1, data1, length); //READ data
FileClose(dataF1); // release file
info1 = atoi(data1);
dataF2 = FileOpen("data2.txt"); // open file
if (dataF2 == 0){ dataF2 = FileCreate("data2.txt"); }
dataF2 = FileOpen("data2.txt");
length = strlen(data2);
FileRead(dataF2, data2, length); //READ data
FileClose(dataF2); // release file
info2 = atoi(data2);
dataF3 = FileOpen("data3.txt"); // open file
if (dataF3 == 0){ dataF3 = FileCreate("data3.txt"); }
dataF3 = FileOpen("data3.txt");
length = strlen(data3);
FileRead(dataF3, data3, length); //READ data
FileClose(dataF3); // release file
info3 = atoi(data3);
}
|