File output

1
2
3
4
ofstream File("test.txt");
	string f;
	cin >> f;
	File << f;



shouldn't these lines of code work?
Possibly. Are you having some sort of problem with them?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <fstream>
#include <string>
#include <iostream>

main()
{
      std::string f;
      
      std::ofstream myfile;
      myfile.open("test.txt");
      
      std::cin >> f;
      std::cin.get();
      myfile << f;
      
      std::cin.get();
}
have no idea what the problem was or how it was fixed it just happens to work now thanks anyway guys
Topic archived. No new replies allowed.