Thread: Unix pathname to Windows pathname

  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, 08: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, 03: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, 03:37 PM