Thread: writing to certain locations.

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    86

    writing to certain locations.

    how do u write a file to c:\ for example?

    if u do this: ofstream ("c:\lol.dat",ios:ut) and u run the program from your desktop it will just be placed on the desktop, but when i run it directly from my cppbuilder it does go to c:\

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    If you use ofstream my_stream("c:\\lol.dat"); and write out to my_stream, it will be written to C:\lol.dat. When using backslashes inside strings in C++, you need to escape it with an extra backslash. You could also use ofstream my_stream("c:/lol.dat") since the forward slash does not need to be escaped.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    86
    aight, cool thanx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-20-2008, 08:57 AM
  2. Very slow file writing of 'fwrite' function in C
    By scho in forum C Programming
    Replies: 6
    Last Post: 08-03-2006, 02:16 PM
  3. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  4. help! fifo read problem
    By judoman in forum C Programming
    Replies: 1
    Last Post: 08-16-2004, 09:19 AM
  5. Writing to Specific Locations
    By Spex in forum C Programming
    Replies: 5
    Last Post: 02-14-2002, 10:08 PM