On Thu, Nov 6, 2008 at 3:01 PM, Brett McCoy <[EMAIL PROTECTED]> wrote:
> On Thu, Nov 6, 2008 at 7:54 AM, Tamas Marki <[EMAIL PROTECTED]> wrote:
>
>>>> I have written a program to create a file.The file always get created
>>>> in Bin folder.How to create a file in other folders of desired
>>>> location.
>>>> Please reply soon.
>>> Where's your code? Just provide the full path to the directory you
>>> want to open the file in.
>>> fopen("C:\Users\bmccoy\Music\myfile.txt", "w");
>>
>> Sorry for the nitpick, but you forgot to escape the backslashes (and
>> for newbies it could produce a not too obvious error). The correct way
>> would be:
>> fopen("C:\\Users\\bmccoy\\Music\\myfile.txt", "w");
> That's required for Windows paths now? I don't do much Windows
> programming these days, but don't recall having to escape the
> backslashes in the past.

Even in Turbo C++ you had to escape backslashes, because they denote
special characters, otherwise things like

fopen ("c:\tmp\new.txt");

would be considered as opening a file named "c:<tab>mp<newline>ew.txt".

On the other hand the forward slash notation also works under Windows
since at least Windows 2000 (possibly earlier).

-- 
Tamas Marki

Reply via email to