I came across an idea where I wanted to log what my program is doing with date and time. So I wrote a small function, and upon compilation no error, and no runtime error except that it doesn't open log.txt and it won't even display the date. I must be mistaken because last night, this code was working and I don't remember changing anything(apparently I must've) and I can't figure out what the issue is.
#include <chrono>
#include <ctime>
#include <fstream>
#pragma waing(disable:4996)
void log(const char*& text)
{
std::fstream fs;
fs.open("log.txt", std::fstream::in | std::fstream::out | std::fstream::app);
auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
fs << ctime(&now) << text << std::endl;
}
int main()
{
const char* log("Testin codenz stuff");
}
