Example of File I/O
#include <string>
#include <fstream>
#include <iostream>
#include <sstream>
using namespace std;
int Main()
{
//Variables to write
int Var1 = 1234;
float Var2 = 5.678;
char* Var3 = "ABC";
string Var4 = "WXZ";
//String Var
string LineRead;
//File Handle
fstream MyFileA("Test.txt");
// Write to file
if (MyFileA.is_open())
{
cout << "Write to file part..." << endl;
//Write to file;
MyFileA << Var1;
MyFileA << Var2;
MyFileA << Var3;
MyFileA << Var4;
count << "Variables written." << endl;
}
MyFileA.close();
// Read Vairables
fstream MyFileB ("Test.txt");
if (MyFileB.is_open())
{
while(!MyFileB.eof())
{
getline(MyFileB,LineRead);
cout << LineRead << endl;
}
}
MyFileB.close();
system("pause");
return -1;
}
thats a basic idea of file i/o. any questions, just ask.
I soon plan to release a dlls that i created, one of them is a file dll for writing to and from text files.
Problem Solution That Never Fails: "Build A Bridge And Get Over It"