Unix pathname to Windows pathname

This is a discussion on Unix pathname to Windows pathname within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I am trying to compile my unix c++ code in windows, but am having file path trouble. My unix ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    6

    Unix pathname to Windows pathname

    Hi,

    I am trying to compile my unix c++ code in windows, but am having file path trouble. My unix code is:

    Code:
      cout << "Enter output sub-folder name: ";
      cin >> fn;
      subFolder = fn;
      fnfull = "./" + fn + "./scores.data";
      fout.open(fnfull.c_str(), ofstream::out);
    This does not work properly when compiled in windows. I also tried:

    Code:
      cout << "Enter output sub-folder name: ";
      cin >> fn;
      subFolder = fn;
      fnfull = fn + "\\scores.data";
      fout.open(fnfull.c_str(), ofstream::out);
    With no sucess.

    Any help would be appreciated.

    cheers.
    Last edited by Salem; 12-01-2005 at 02:08 AM. Reason: REALLY fix the tags!

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    I wouldn't expect the first example to work in *nix either.
    fnfull = "./" + fn + "./scores.data";

    if fn == "Hello" then the result of the above is
    "./Hello./scored.data"

    Which is probably not correct unless directory names can have a trailing period "Hello."

    The second example should work unless fn contain trailing '\' character. If fn == "c:\windows" then the result should be "c:\windows\scores.data".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to program in unix
    By Cpro in forum Linux Programming
    Replies: 21
    Last Post: 02-12-2008, 10:54 AM
  2. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 09:39 AM
  3. How May I connect from Windows NT to Unix
    By jose luis in forum C Programming
    Replies: 3
    Last Post: 08-22-2002, 04:12 PM
  4. Windows or Unix environment
    By ghe1 in forum Windows Programming
    Replies: 5
    Last Post: 02-19-2002, 11:37 AM
  5. unix, windows
    By stef in forum C Programming
    Replies: 3
    Last Post: 09-14-2001, 04:37 PM

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