private: System::Void SaveData_Click(System::Object^ sender, System::EventArgs^ e) {
if(AttachedState == TRUE)
{
double TTemperature = TemperatureValue/2.0;
double TTemperature1 = TemperatureValue1/2.0;
String^ fileName = "MonitoringData-%date:~4,2%-%date:~7,2%-%date:~12,2%.txt";
StreamWriter^ sw = gcnew StreamWriter(fileName);
sw->WriteLine("Data Logged at {0}",DateTime::Now);
sw->WriteLine("");
sw->WriteLine("Temperature : {0} Degree Celsius", TTemperature);
sw->WriteLine("Temperature1 : {0} Degree Celsius", TTemperature1);
sw->WriteLine("");
sw->WriteLine("Data Logged Using Monitoring System (c) 2010 Sunny Group");
sw->Close();
MessageBox::Show( "File Saved!","Save Complete!",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation );
}
if((AttachedState == FALSE) || (AttachedButBroken == TRUE))
{
MessageBox::Show( "Please Connect Monitoring System!","Save Data Error!",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation );
}
}
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int main () {
int idata=23;
float fdata=3.14159f;
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile << "integer " << idata << " float " << fdata << endl;
myfile.close();
return 0;
}
Writing this to a file.
integer 23 float 3.14159
#include <iostream>
#include <fstream>
using namespace std;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?