file indexing in windows and unix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Man4ish
    New Member
    • Mar 2008
    • 151

    file indexing in windows and unix

    Hi,
    I have written one program in C++ for file indexing and searching keyword which is working fine on unix. But on windows it may work differently reason being the /r/n at the end of line. While on unix it has /n only. How one program can be made intelligent enough to work same on different platforms.

    Manish
  • wastman
    New Member
    • Apr 2009
    • 17

    #2
    No pa.

    Originally posted by Man4ish
    Hi,
    I have written one program in C++ for file indexing and searching keyword which is working fine on unix. But on windows it may work differently reason being the /r/n at the end of line. While on unix it has /n only. How one program can be made intelligent enough to work same on different platforms.

    Manish
    You should not post questions here.this is insights part.
    you can post articles here.go to the answers part.

    Comment

    • Man4ish
      New Member
      • Mar 2008
      • 151

      #3
      file indexing in windows and unix

      Hi,
      I have written one program in C++ for file indexing and searching keyword which is working fine on unix. But on windows it may work differently reason being the /r/n at the end of line. While on unix it has /n only. How one program can be made intelligent enough to work same on different platforms.

      Manish

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        It rather depends for instance if you are only dealing with text files then you could open the files in text mode which converts the default OS line ending to a /n on reading and vice versa on writing.

        Alternatively you could do something like treating /r as a space when your program sees it.

        You need to find a logical way to handle /r that is going to continue to work if you encounter a /r in a file on a unix system.

        Comment

        • Nepomuk
          Recognized Expert Specialist
          • Aug 2007
          • 3111

          #5
          I found something that should help: Check this article, especially the chapter Proper #ifdef's when porting.

          But wastman is absolutely right, this is the "insights" section and such questions belong in the "answers" section. I know, it can be confusing, but please try to post in the right place from now on.

          Greetings,
          Nepomuk

          Comment

          Working...