reading and creating a file path

This is a discussion on reading and creating a file path within the C++ Programming forums, part of the General Programming Boards category; I wrote this program that reads a file on my drive and then puts an updated version of that file ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    1

    reading and creating a file path

    I wrote this program that reads a file on my drive and then puts an updated version of that file on the desktop. The program will reside in a different place. the path is something like this
    output file "c:\documents and settings\greg\desktop\blahblahblah.htm"
    input file "C:\documents and settings\greg\desktop\info.htm"

    the complier won't read the path and throws a few warnings cause it wants to use '\' as an excape character.

    i'm not sure what to do cause i've only rarely used file IO.

    thanks for any help.

  2. #2
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    that's correct, compiler normally treats "\" (back slash) as an escape character, what you need to use is double back slash "\\" , which in turn is an escape character that "escapes and treats the next character as a back slash itself....


    Code:
    ex...
          
      "c:\\documents and settings\\greg\\desktop\\blahblahblah.htm"

    also on some compilers you can simply use a "forward slash" "/" instead of double back slash, but remember that's compiler dependant....

    hope this helps

    Good luck

    matheo917

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 01:44 PM
  2. reading, editing and creating a new file
    By s_jsstevens in forum C Programming
    Replies: 3
    Last Post: 04-27-2007, 03:40 PM
  3. Reading from file and crashing
    By Night_Blade in forum C++ Programming
    Replies: 1
    Last Post: 09-25-2005, 02:09 AM
  4. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM
  5. Creating And Reading From A File
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 10-17-2001, 09:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21