Trying to use PuTTY to write to a file (lang is C++)

I am using putty to write some of my C++ programs in. I locate my directory, and i made a file in my home directory named "name.txt". My name.txt file and my program (which is named "PuttyTest.cpp) are both in the same directory. However when I run this program below, then go to open up the name.txt file in Putty, nothing appears there. I am assuming my name.txt isn't in the right folder but I'm not sure which one it needs to be in.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <fstream>
using namespace std;

int main() {
ofstream myfile;
myfile.open("name.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}

Last edited on
Try adding this piece of code before int main()

1
2
3
4
5
#include <iostream>
#include <fstream>
using namespace std;

int main()
Oh it's in there I'm just it just didn't copy and paste for some reason
Topic archived. No new replies allowed.