- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.cpp
More file actions
Latest commit
23 lines (21 loc) · 525 Bytes
/
Copy pathserver.cpp
File metadata and controls
23 lines (21 loc) · 525 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<ctime>
#include<fstream>
#include<iostream>
char timeBuffer[256];
time_t rawtime;
structtm* currentTime;
intmain()
{
std::string str;
std::ifstream serialInput;
std::ofstream fileOutput;
serialInput.open("/dev/cu.usbmodem411");
fileOutput.open("WaterData", std::fstream::app);
while (serialInput >> str)
{
time(&rawtime);
currentTime = localtime(&rawtime);
std::strftime(timeBuffer, sizeof(timeBuffer), "%d/%m/%y-%H:%M:%S", currentTime);
fileOutput << timeBuffer << "" << str << '\n';
}
}