»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 04-14-2004, 08:44 PM   #1 (permalink)
Registered User
 
Join Date: Oct 2003
Posts: 72
amtrac24 is on a distinguished road
c++ / Linux Help

Hey guys,

Im trying to use a command in c++ (KDevelop) and i cant seem to find it on the web or figure it out. I am trying to use a system call

system("cd /dos/Program Files/");

Basically referring to my mounted ntfs drive. The problem i am getting is its not reading the Program Files directory because it cuts off after the Program word. I tried everything from system("cd /dos/Program\ Files/"; etc with different combinations but with no success.

Here is the exact error i am receiving :
rash: line 1: cd: /dos/Program: No such file or directory
sh: line 1: Files: command not found


anyone know how i can get to this directory.

P.S. i tried put the info into a string but that didnt work either.

amtrac24 is offline   Reply With Quote
Old 04-14-2004, 08:50 PM   #2 (permalink)
Registered User
 
Join Date: Aug 2002
Posts: 63
soulware is on a distinguished road
I'm not on UNIX right now, but system("cd \"/dos/Program Files/\""); should work
soulware is offline   Reply With Quote
Old 04-14-2004, 08:52 PM   #3 (permalink)
Registered User
 
Join Date: Aug 2002
Posts: 63
soulware is on a distinguished road
if that doesn't work try system("cd /dos/Program\\ Files/");
soulware is offline   Reply With Quote
Old 04-14-2004, 08:54 PM   #4 (permalink)
Guest
Guest
 
Posts: n/a
While this is not a good solution, try "Progra~1" instead of "Program Files".

Robert Richmond
  Reply With Quote
Old 04-14-2004, 08:58 PM   #5 (permalink)
Registered User
 
Join Date: Oct 2003
Posts: 72
amtrac24 is on a distinguished road
nice job guys

Wow, you guys shocked me with the amount of responses within 5 minutes. You guys come through in the clutch again. RobRich, you get the medal even though soulware was close. The Progra~1 worked for some reason. Even though when you navigate in the terminal it shows Program Files the Progra~1 worked for some reason. RobRich you have the philosphy why that worked? or you just took a guess?

thanks for your help guys
amtrac24 is offline   Reply With Quote
Old 04-14-2004, 09:05 PM   #6 (permalink)
Registered User
 
Join Date: Oct 2003
Posts: 72
amtrac24 is on a distinguished road
Soulware was correct too

Soulware btw you were right too your ("cd \"/dos/Program Files/\""); works
amtrac24 is offline   Reply With Quote
Old 04-14-2004, 09:07 PM   #7 (permalink)
Guest
Guest
 
Posts: n/a
It is related to how DOS works with the FAT32 format. You needed to get the long filename (directory in this case) to a 8.3 (8 for directory) format.

Look up information for the GetShortPathName C++ convention.

Better methods exist, such as soulware's solution, but I went for the "quick and dirty" hack in true old-school Microsoft C++ fashion.

Robert Richmond
  Reply With Quote
Old 04-14-2004, 11:51 PM   #8 (permalink)
Registered User
 
Join Date: Dec 2003
Posts: 24
torac is on a distinguished road
since were on the c++ topic

Hey guys since were on the c++ topic. I wonder if soulware, or RobRich could help me out with something.

int main(int argc, char *argv[])
{
char enter[60];
int count=0;

cout<<"Please Name:\n";
cin>>enter;


if (enter=="Mike")
count=1;


cout<<count;
return EXIT_SUCCESS;
}


When i get the cout of the count before the return i end up with it saying 0. Even though when i enter "Mike" it skips over the count=1. I tried
if (enter=="Mike")
{
count=1;
}

and that did not work either. I tried several examples with switch and if statements using strings. Can anyone help me with this code. Basic question is how to compare strings. Thanks for your help guys
torac is offline   Reply With Quote
Old 04-15-2004, 12:32 AM   #9 (permalink)
Guest
Guest
 
Posts: n/a
http://lcvmwww.epfl.ch/~caussi/TPs/c...lusplus04.html
http://h30097.www3.hp.com/cplus/clu014.htm

I am not the best person for answering C++ questions, as it has been way too many years since I set through a C programming class. My last major development class was Fortran, and that pretty much fried my brain for all other programming languages.

Robert Richmond
  Reply With Quote
Old 04-15-2004, 07:24 AM   #10 (permalink)
Registered User
 
SpookyEddy's Avatar
 
Join Date: Oct 2001
Location: UK
Posts: 3,125
SpookyEddy is on a distinguished road
Code:
#include <iostream>

int main()
{
  using namespace std;

  string enter;
  int count = 0;

  cout << "Please Enter Name: ";
  cin >> enter;

  if (enter == "Mike")
    count = 1;

  cout << count << endl;
  
  return 0;
}
Results in...
Code:
ed@Slacker:~/cpp$ ./mike 
Please Enter Name: Mike
1
ed@Slacker:~/cpp$ ./mike 
Please Enter Name: foo
0
ed@Slacker:~/cpp$
Regards

ed

Last edited by SpookyEddy; 04-15-2004 at 07:29 AM.
SpookyEddy is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 06:43 PM.