Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Please Help

  1. #1
    chetan21 is offline Newbie
    Join Date
    May 2009
    Posts
    14
    Blog Entries
    1
    Rep Power
    0

    Please Help

    I am writing a program to open a folder which is like
    Code:
    #include <stdlib.h>
    int main()
    {
    char STRG[80]="";
    char STRG1[80]="explorer //C$/ettings/Tj/Dp";
    system(STRG1);
    }
    it should take path "//C$/ettings/Tj/Dp"
    but it is taking "/C$/ettings j/Dp"
    I know that compiler do not read \t,\\ as a normal character but then whats the solution?
    Last edited by Jaan; 08-09-2009 at 02:22 PM. Reason: Use code tags when you are posting your codes!

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: Please Help

    I guess you would have to escape your path:

    \\\\C$\\Settings\\Tj\\Dp
    __________________________________________
    I study Information Systems at Karlstad University when I'm not on CodeCall

  4. #3
    Join Date
    Jul 2008
    Location
    Somewhere that is shorter to write than "In the gloomy shadows of my personal namespace"
    Posts
    10,725
    Blog Entries
    2
    Rep Power
    90

    Re: Please Help

    Yeah, explorer takes paths with backslashes, which are used for escape characters in C and C++, so you'll have to write \\ for one \.
    Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

  5. #4
    mindblaster's Avatar
    mindblaster is offline Newbie
    Join Date
    Jul 2009
    Posts
    17
    Rep Power
    0

    Re: Please Help

    yes its fault of escape sequences.

    Join SuperDiscountShop.com at Facebook.

  6. #5
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Please Help

    No, it's Windows' fault. Everyone else (i.e. MacOS, Linux, UNIX, etc.) uses the forward slash. I would suggest using MAX_PATH as the buffer size, by the way. Less chance of buffer overruns. Or better yet, use a C++ string and then just call

    Code:
    std::string path = "explorer C:\\really\\long\\path";
    system(path.c_str());
    sudo rm -rf /

  7. #6
    mhaqs is offline Newbie
    Join Date
    Aug 2009
    Posts
    1
    Rep Power
    0

    Re: Please Help

    You just need to understand it all for Windows. It is the opposite for all other OSes.

  8. #7
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Please Help

    Exactly. Welcome to CodeCall, mhaqs.
    sudo rm -rf /

  9. #8
    Join Date
    Jul 2008
    Location
    Somewhere that is shorter to write than "In the gloomy shadows of my personal namespace"
    Posts
    10,725
    Blog Entries
    2
    Rep Power
    90

    Re: Please Help

    lol yeah it's weird really..
    Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

  10. #9
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Please Help

    I know! Windows is written in C...didn't anyone notice that it's incredibly annoying to write \\\\.\\A\\: every time you want to open a directory for reading? One of the last things I wrote for Windows was this tool that collected partition information out of every valid drive. That was a pain.
    Last edited by dargueta; 08-14-2009 at 04:59 AM. Reason: Forgot to make a snide comment
    sudo rm -rf /

  11. #10
    Join Date
    Jul 2008
    Location
    Somewhere that is shorter to write than "In the gloomy shadows of my personal namespace"
    Posts
    10,725
    Blog Entries
    2
    Rep Power
    90

    Re: Please Help

    Perhaps Microsoft developers are sadomasochists..
    Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts