Support Forums

Full Version: Help with naming a txt!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I need a code that when I run the program it asks me to enter a name and when I press enter it creates a file named exactly as I typed in and to be .txt

And other thing is how to make the file be created on desktop or some other folder and not in same directory where program is!?
You should really consider learning the basics of C++.
i can help this thing on vb.net but c++ Sad
(07-01-2011, 09:57 AM)0xE9 Wrote: [ -> ]You should really consider learning the basics of C++.

Yeah I know basics but I have problem wit this! Its all my teacher explained only not how to do this and It is pissing me off!
(07-01-2011, 09:57 AM)0xE9 Wrote: [ -> ]You should really consider learning the basics of C++.

I was going to say that.
Great if you all are so clever will someone help! It is support forum dam don't be assholes! Help or don't bother posting!
easy as hell man
do you need a graphical user interface or a command line version?


Dude this is easy, you need to learn some more about C++
wut is your ide btw?
visual studio, qt creator, codeblcocks (etc)

anyways I am at school and I dont have my programming companion (qt creator) with me put fire this up and tell me if it works. this will support a CL interface, so make a new "console C++ application".. from here it is very easy to port it to a GUI with an inputbox and button
Code:
#include <iostream>
  #include <fstream>
  using namespace std;
  int main () {
  ofstream myfile;
  int filename;
  cout << "Please enter a text file name: ";
  cin >> filename;
  cout << "text file " << filename;
  myfile.open (filename);
  myfile << "Writing this to a file.\n";
  myfile.close();
  return 0;
}
yeah, you should learn the basics before doing anything else, try reading tutorials
Pages: 1 2