I'm beginning to think this is totally impossible... 

I have a small console programme that is basically a small calculator, once the user has done one calculation and achieved a result the programme then loops to allow the user to do another calculation. As long as the user keeps choosing to add another calculation the programme is never ending.

Now what I would like is to be able to save ALL of the data displayed in the console to a new text file on the desktop.

I have a set of functions that declares a full file path and file name into a string, if possible I would like the programme to save the text file to this exact file path and name. If not possible then the user’s desktop will do fine. 

So far I have tried Fstream but had no luck; maybe I'm doing something wrong? I'm kind of new to this all so any help would be greatly appreciated.

Below is ALL code from the programme. 

```
#include <iostream>
#include <ctime>
#include <string>
#include <sstream>
#include <windows.h>
#include <Lmcons.h>
using namespace std;

int main()
{
   //creates file name
    char timeNow[20];
    time_t now = time(NULL);
    strftime(timeNow, 20, "%d.%m.%Y %H%Mhrs", localtime(&now));

// Creates desktop file path that includes the users user name
char username[UNLEN+1];
DWORD username_len = UNLEN+1;
GetUserName(username, &username_len);
stringstream user;
string UserName;
user << username;
user >> UserName;
string pathName = "c:/users/" + UserName + "/desktop/" + timeNow + ".txt";

// Declare Variables
int suA, splitA, cornerA, streetA, sixlineA, payout;
double Cvalue = 1;
double cash;
int winnum = 0;
int table = 0;
std::string Another ("y");

// Programme Header
cout << "Roulette Bet Calculator & Payout Log!" << endl;
cout << "By Chris McCarthy" << endl << endl;

    //Bet Calculator Loop
    while (Another == "y") {
    cout << "Table no: AR";
    cin >> table;
    cout << "Winning Number? ";
    cin >> winnum;
    char timeNow[20];
    time_t now = time(NULL);
    strftime(timeNow, 20, "%H:%M:%S %d/%m/%Y", localtime(&now));
    cout << timeNow << endl << endl;
    cout << "Please enter the chip value? " << char(156);
    cin >> Cvalue;
    cout << "Please enter the amount of Straight Ups? ";
    cin >> suA;
    cout << "Please enter the amount of Splits? ";
    cin >> splitA;
    cout << "Please enter the amount of Corners? ";
    cin >> cornerA;
    cout << "Please enter the amount of Streets? ";
    cin >> streetA;
    cout << "Please enter the amount of Six Lines? ";
    cin >> sixlineA;
    cout << endl;

    // Calculates then writes the final payout and cash value
    payout  = (suA * 35) + (splitA * 17) + (cornerA * 8) + (streetA * 11) + (sixlineA * 5);
    cash = Cvalue * payout;
    cout << "The payout is: " << payout << endl;
    cout << "The cash value of the payout is: " << char(156) << cash << endl << endl;

    // Adds another bet or terminates programme
    cout << "Add another bet? (y/n) ";
    cin >> Another;
    cout << "____________________________________________________________" << endl << endl;
}
return 0;
}

```