Looking for work? Check out our jobs area.

Beginner C/C++

Moderators: Lundin
Number of threads: 4931
Number of posts: 15978

This Forum Only
Post New Thread

Report
How to create a file in a certain directory in windows? Posted by Newbcoder on 7 Dec 2009 at 2:05 PM
#include <iostream>
#include <fstream>
using namespace std;

int main () {
    
  ofstream outfile ("c:\windows\system32\test.txt");
  
  if (outfile)
  {
              cout << "it works";
  }
  


  cin.get();
  return 0;
}


Well, I am trying to create a file in the c:\windows\system32 path. I have googled and it basically told me to do this, but it doesn't seem to be working. I have UAC disabled. I am running windows 7 Ultimate 64-bit.
Report
Re: How to create a file in a certain directory in windows? Posted by anthrax11 on 7 Dec 2009 at 8:33 PM
\t is the tab character. Try this instead:
ofstream outfile ("c:\\windows\\system32\\test.txt");



 
Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2010 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
bootstrapLabs Logo A BootstrapLabs project.