Jump to content

Please Help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
12 replies to this topic

#1
chetan21

chetan21

    Newbie

  • Members
  • PipPip
  • 14 posts
I am writing a program to open a folder which is like
#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?

Edited by Jaan, 09 August 2009 - 01:22 PM.
Use code tags when you are posting your codes!


#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,298 posts
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

#3
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
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

#4
mindblaster

mindblaster

    Newbie

  • Members
  • PipPip
  • 17 posts
yes its fault of escape sequences.
Posted Image
Join SuperDiscountShop.com at Facebook.

#5
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
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

std::string path = "explorer C:\\really\\long\\path";
system(path.c_str());

sudo rm -rf /

#6
mhaqs

mhaqs

    Newbie

  • Members
  • Pip
  • 1 posts
You just need to understand it all for Windows. It is the opposite for all other OSes.

#7
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
Exactly. Welcome to CodeCall, mhaqs.
sudo rm -rf /

#8
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
lol yeah it's weird really..
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#9
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
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.

Edited by dargueta, 14 August 2009 - 03:59 AM.
Forgot to make a snide comment

sudo rm -rf /

#10
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
Perhaps Microsoft developers are sadomasochists..
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#11
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
Which is why I switched over to Linux this summer. Sooo much better, though I haven't tried doing anything fancy yet.
sudo rm -rf /

#12
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Linux "just works", Windows is consistently a pain. I've gotten so burned on Vista that I can't be bothered to try anything post XP.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog