ifstream files

This is a discussion on ifstream files within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by dwks I would prefer, however, to supply "./" or no path... Bzuh? Windows uses ".\", even though ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Quote Originally Posted by dwks View Post
    I would prefer, however, to supply "./" or no path...
    Bzuh? Windows uses ".\", even though "./" works

    Finally, from my limited experience with Microsoft Visual C++, I think it puts your executable in a Debug/ or Release/ subdirectory of the main project directory, depending on which mode you compiled the program in.
    Nope. It puts them in the "Debug\" and "Release\" by default
    But it's possible to change this. I typically specify...
    $(SolutionDir)Application\$(ConfigurationName)
    ...as output directory.
    Which defaults to something like (Path_to_your_solution)\Application\Debug.
    There are my app including any dlls and such it may need. So it isn't littered by all the intermediate files (which are placed in the intermediate directory by default. Handy.

    You could try using "../input.in" or copying/moving the input file to this subdirectory.
    Nope, that would be "..\input.in"
    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
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Oh really? http://www.thescripts.com/forum/thread23123.html

    I tend to use forward slashes for directory separators all of the time, because they work in Linux and UNIX and similar systems, and in Windows as well. Even Mac OS X supports them.
    This reminds me that another thing to look out for between windows and macs, is filename sensitivity. Mac and other UNIX systems, use case-sensitive filenames. So it is a good idea to reference files exactly as they are named. It is also good idea to use a forward slash (/) to separate directories. It seems that all systems windows, mac, and linux understand / as the directory separator, but only windows understands backslash (\).
    From http://forums.rpgdx.net/viewtopic.ph...1bbddfd8016dbf

    Another excellent reason to use forward slashes is that you don't have to escape them with \\ all of the time in your code.

    More information about where MSVC puts its executables: fopen..
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    I never said Windows didn't support them. It does, but translates them to "\" instead.
    And I really, really hate "/". It looks disgusting IMHO. So I always use "\".
    Windows API supports "/", but not anything else, so don't go using "/" with system().
    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
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Quote Originally Posted by Elysia View Post
    I never said Windows didn't support them.
    No, but you sort of implied it with all of those "nope"s.

    It does, but translates them to "\" instead.
    How do you know? I would think someone, somewhere, just used
    Code:
    if(c == '\\' || c == '/') {
        /* ... */
    }
    And I really, really hate "/". It looks disgusting IMHO. So I always use "\".
    I'm just the opposite, but that's because I use Linux all of the time. I guess you never use Linux, or you'd know what a pain it is to convert slashes . . . .
    Windows API supports "/", but not anything else, so don't go using "/" with system().
    Well, and the standard C and C++ libraries.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #20
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Quote Originally Posted by dwks View Post
    No, but you sort of implied it with all of those "nope"s.
    I did that because Windows filesystem uses "\" and I really don't like "/"

    How do you know? I would think someone, somewhere, just used
    Code:
    if(c == '\\' || c == '/') {
        /* ... */
    }
    Because it's documented on MSDN. All Windows API translates "/" to "\" for paths.

    I'm just the opposite, but that's because I use Linux all of the time. I guess you never use Linux, or you'd know what a pain it is to convert slashes . . . .
    I'll tell you, I'd go mad with the Linux filesystem instead of getting used to it.
    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.

  6. #21
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by Elysia View Post
    And I really, really hate "/". It looks disgusting IMHO. So I always use "\".
    Now that's funny.

  7. #22
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Because it's documented on MSDN. All Windows API translates "/" to "\" for paths.
    Well, that may be so, but you didn't say that the Windows API did the translation; you said that Windows did the translation, which is different. And of course, I wasn't sure how you'd be able to tell how Windows did things, being closed source as it is.

    Besides, though Windows comes up a lot in this thread, I don't think the OP ever says that they use Windows. (I may have missed an implied reference in my quick scan.) Thus, my use of forward slashes is an even better idea. (Of course, I was talking about MSVC for some of my post, but not all of it.)

    And we've been ignoring this:
    Another excellent reason to use forward slashes is that you don't have to escape them with \\ all of the time in your code.
    It's a big factor, it really is.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #23
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Quote Originally Posted by dwks View Post
    Besides, though Windows comes up a lot in this thread, I don't think the OP ever says that they use Windows. (I may have missed an implied reference in my quick scan.) Thus, my use of forward slashes is an even better idea. (Of course, I was talking about MSVC for some of my post, but not all of it.)
    I did a quick scan as well, but decided to go ahead with it because you mentioned Windows first.

    It's a big factor, it really is.
    Nah. I typically use a utility to convert paths. And I don't really write much absolute paths anyway, so it's not really a big factor.
    "/" for directories is just wrong
    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.

  9. #24
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    > And I really, really hate "/". It looks disgusting IMHO. So I always use "\".

    Why is the DOS path character "\"?

    Basically, in DOS, "/" was already being used for something else, so they reluctantly decided to use "\" instead. Other than that, there was no good reason for it, especially since AFAIK "/" is always on the same key as "?" on the keyboard, but "\" isn't as easy to reach, not to mention it's not always in the same place.

  10. #25
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Quote Originally Posted by robatino View Post
    ...especially since AFAIK "/" is always on the same key as "?" on the keyboard, but "\" isn't as easy to reach, not to mention it's not always in the same place.
    Is not.
    "\" is on the same key as "?".
    "/" is on key "7".
    Ohohohoho!
    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.

  11. #26
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    That's weird, every keyboard I've seen has "/" and "?" on the same key, including the Dell machine I'm using now, which originally had XP only installed, and came with this keyboard.

  12. #27
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    And what country is that?
    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.

  13. #28
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Is not.
    "\" is on the same key as "?".
    "/" is on key "7".
    Ohohohoho!
    With standard US keyboards, / and ? share the same key. SHIFT-7 is &. http://upload.wikimedia.org/wikipedi...oAltGr.svg.png

    It looks like you're using a Spanish keyboard, am I right? http://upload.wikimedia.org/wikipedi...erican.svg.png

    Details: http://en.wikipedia.org/wiki/Keyboard_layout#QWERTY

    Basically, in DOS, "/" was already being used for something else, so they reluctantly decided to use "\" instead. Other than that, there was no good reason for it, especially since AFAIK "/" is always on the same key as "?" on the keyboard, but "\" isn't as easy to reach, not to mention it's not always in the same place.
    Plus "\" was invented because they didn't feel like using alternative notation like "|" or "&".

    I did a quick scan as well, but decided to go ahead with it because you mentioned Windows first.
    Aha, I found it. The OP actually mentioned it first.
    I'm using Microsoft Visual C++ to build the program
    My search only searched the text of my reply, as usual, not the whole thread. Sigh.
    Last edited by dwks; 03-05-2008 at 01:18 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  14. #29
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Quote Originally Posted by Elysia View Post
    And what country is that?
    It's a US IBM keyboard. The "\" and "|" characters are on the same key, just under the backspace key, which is not the easiest place to reach.

    Edit: It looks like this:

    http://www.logicapproach.com/index.p...0e150378653de5

  15. #30
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Indeed, but US uses a weird keyboard in itself.
    And of course it's easy to reach.
    US keyboards are not standard, so don't go assuming everyone has a similar keyboard.
    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.

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create Copies of Files
    By Kanshu in forum C++ Programming
    Replies: 13
    Last Post: 05-09-2009, 07:53 AM
  2. Error opening files in a different dir
    By Ozzie in forum C++ Programming
    Replies: 3
    Last Post: 10-09-2008, 06:55 AM
  3. Working with muliple source files
    By Swarvy in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2008, 08:36 AM
  4. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  5. ofstream and ifstream for searching and writing
    By johnnyd in forum C++ Programming
    Replies: 6
    Last Post: 03-17-2003, 07:34 AM

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