#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Location
    India
    Posts
    65
    Rep Power
    20

    Question Unable to convert normal path (Windows) into Path with '\\' In C.


    Hello Friends,
    I am writing one module in which i need to convert the path of directory (Windows) but the problem is the path is without '\\' means it is separated with single '\' I have tried to write but unable to code when i put condition for checking '\u' and '\U'. If there is any other predefined library which will convert the normal path into valid C path kindly suggest me.If there are any other way to solve this problem kindly share it with me. Thank you.
  2. #2
  3. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,117
    Rep Power
    1803
    Why do you need to do this?

    The "\\" is only required in literal string and literal character constants in C code; that is to say, you need them in your code, but not in your input or stored data. It is stored in memory as a single '\', so explicitly storing two '\' seems like an unlikely requirement and would render the path invalid.

    If you are reading a string from an input source at run-time you do not need (and indeed should not) insert an extra '\' - it is meaningless. It would only be required if your code were actually generating C code for compilation that included string literals for file system paths.

    The '\' is used in string literals and literal character constants to introduce special "non printing" characters using escape sequences (e.g. '\r', '\t', '\b'), therefore when you need a literal '\', you need an escape sequence for that too, i.e. '\\', but it nonetheless resolves to a single '\'. All the escape sequences resolve to a single character in memory.
    Last edited by clifford; May 31st, 2013 at 11:09 AM.

IMN logo majestic logo threadwatch logo seochat tools logo