Thread: open file error

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No, "\text.txt" is a valid file name, just as ".\text.txt" or "..\text.txt" are - they are relative filename not absolute filenames, but nevertheless, valid.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    no, ".\text" is a name with . + tab + "ext.txt", which is not valid.
    Use any character in the current code page for a name, including Unicode characters, except characters in the range of zero (0) through 31, or any character that the file system does not allow. A name can contain characters in the extended character set (128–255). However, it cannot contain the following reserved characters:

    < > : " / \ | ? *
    Last edited by robwhit; 12-19-2007 at 06:28 PM.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It's a path. Though I don't know if CreateFile will interpret an absolute path or directory of if it will just accept a filename in the current directory.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Quote Originally Posted by Elysia View Post
    It's a path. Though I don't know if CreateFile will interpret an absolute path or directory of if it will just accept a filename in the current directory.
    Ummmm...

    No it is not.

    A '\' is not a character. A '\' requires a second character in all cases.

    '.\\' or '..\\' is a path

    As Robwhit said, the compiler reads '\t' as a TAB, making '.\text.txt' == '. ext.txt'

    I suggest you try this in your compiler and report your results.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #20
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    And why don't you just use CFile and CArchive if you are using MFC in the first place??

  6. #21
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by novacain View Post
    Ummmm...

    No it is not.

    A '\' is not a character. A '\' requires a second character in all cases.

    '.\\' or '..\\' is a path

    As Robwhit said, the compiler reads '\t' as a TAB, making '.\text.txt' == '. ext.txt'

    I suggest you try this in your compiler and report your results.
    We're talking about real paths here, now how you type them in your compiler
    Obviously, in a C++ string, you'd have to type ".\\text.txt", which would translate to ".\text.txt".

    And why don't you just use CFile and CArchive if you are using MFC in the first place??
    Now there's something I just can't agree less with.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #22
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Quote Originally Posted by Elysia View Post
    We're talking about real paths here, now how you type them in your compiler
    Obviously, in a C++ string, you'd have to type ".\\text.txt", which would translate to ".\text.txt".
    I am/was not sure the OP understood that.....

    EDIT: My previous post was directed at the OP (but reads as if directed at you. Which was not my intention, sorry.)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Alright, no harm done
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. file reading
    By gunghomiller in forum C++ Programming
    Replies: 9
    Last Post: 08-07-2007, 10:55 PM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM