Beginner C/C++

Moderators: None (Apply to moderate this forum)
Number of threads: 5248
Number of posts: 16673

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

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");



 

Recent Jobs

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

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 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.
Operated by CommunityHeaven, a BootstrapLabs company.