6 Replies - 41509 Views - Last Post: 16 December 2007 - 08:12 AM Rate Topic: ***** 1 Votes

#1 thejasper  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 02-November 07

how to create a text file

Post icon  Posted 14 December 2007 - 12:05 PM

Hello guys

I have a (little) question. I want to create a textfile automatically if it doesn't exist. Now my program writes to a txt file but you have to put the txt manually together with the exe. Who knows a solution

Thx :)
Is This A Good Question/Topic? 0
  • +

Replies To: how to create a text file

#2 Bench  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 855
  • View blog
  • Posts: 2,338
  • Joined: 20-August 07

Re: how to create a text file

Posted 14 December 2007 - 12:17 PM

That's a bit unclear, do you have an example of what you're trying to do, and the code you're using?
Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: how to create a text file

Posted 14 December 2007 - 12:19 PM

http://www.cplusplus...rial/files.html
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5247
  • View blog
  • Posts: 27,069
  • Joined: 10-May 07

Re: how to create a text file

Posted 14 December 2007 - 12:58 PM

Assuming you are using Linux you could always :

system("touch file");


Was This Post Helpful? 0
  • +
  • -

#5 quim  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 18
  • View blog
  • Posts: 182
  • Joined: 11-December 05

Re: how to create a text file

Posted 14 December 2007 - 09:02 PM

I know that in windows if you open a file, output file not input file, it will be created automatically.
check the like that Amadeus gave you.
ofstream fileout;
fileout.open("anyname.txt");

Was This Post Helpful? 0
  • +
  • -

#6 thejasper  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 02-November 07

Re: how to create a text file

Posted 15 December 2007 - 02:57 AM

problem solved, thx quim and the others :^:
Was This Post Helpful? 0
  • +
  • -

#7 DPR  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 17
  • Joined: 20-December 06

Re: how to create a text file

Posted 16 December 2007 - 08:12 AM

In future, I suggest describing your problem with more detail, and possibly submitting an example of some of the code that you are using to try and achieve whatever it is you are trying to achieve
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1