I am trying to put the filename that I am reading from to the file using this code:
The file is named ABC and this is what I want to write to the file: "file2".
I am trying to type in << myfile << but nothing is written to the file.
I want it to recognice what is written in the paratheses after the declaration of myfile. Is this possible in any way ?
Code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
int main ()
{
std::string Date;
int Time = 0;
char Comma;
ofstream Test;
Test.open ("file2.txt");
ifstream myfile ("ABC.txt");
getline(myfile, Date, ',');
myfile >> Time; // 2111
myfile >> Comma;
if (Time == 2100)
{
Test << myfile << Time <<"\n";
}
return 0;
}