Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 26th, 2006, 4:21 PM   #11
Yarvin
Programmer
 
Join Date: Sep 2005
Location: Anchorage, Alaska
Posts: 37
Rep Power: 0 Yarvin is on a distinguished road
couldn't you try something like:
#include <iostream>

using namespace std;

int main()
{
    char address;
    address = 'C:\\Program Files\\alcohol soft\\alcohol 120\\AxCmd.exe E: /u'
    system(address);
    system("PAUSE");
    return EXIT_SUCCESS;
}
or even:
#include <iostream>

using namespace std;

#define address 'C:\\Program Files\\alcohol soft\\alcohol 120\\AxCmd.exe E: /u'

int main()
{
    system(address);
    system("PAUSE");
    return EXIT_SUCCESS;
}
or something of that sort... just some thoughts... I'm still a noob at C++ ^_^

Last edited by Yarvin; Apr 26th, 2006 at 4:42 PM.
Yarvin is offline   Reply With Quote
Old Apr 26th, 2006, 4:26 PM   #12
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
Quote:
Originally Posted by nnxion
Dang DOS 8.3 format. I should disable it.
ooh, nice trick
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Old Apr 26th, 2006, 4:38 PM   #13
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
@Lich: if you do that, the ~1 trick might not work anymore.

@Yarvin: there are two problems with your solution:
1- '\' is considered an escape character that cannot be used in strings. To use it, we do '\\'.
2- System() will not accept spaces within the command string.
OpenLoop is offline   Reply With Quote
Old Apr 26th, 2006, 4:45 PM   #14
Yarvin
Programmer
 
Join Date: Sep 2005
Location: Anchorage, Alaska
Posts: 37
Rep Power: 0 Yarvin is on a distinguished road
Quote:
Originally Posted by OpenLoop
@Yarvin: there are two problems with your solution:
1- '\' is considered an escape character that cannot be used in strings. To use it, we do '\\'.
2- System() will not accept spaces within the command string.
Okay... So I get the escape character, but I don't quite understand the space problem within System(). In my code I'm using a variable in place of the address so there isn't a space in System(). Maybe I just don't understand what you mean by System() not accepting spaces.....
Yarvin is offline   Reply With Quote
Old Apr 26th, 2006, 4:57 PM   #15
Prm753
Professional Programmer
 
Prm753's Avatar
 
Join Date: Oct 2005
Location: United States
Posts: 447
Rep Power: 4 Prm753 is on a distinguished road
Send a message via AIM to Prm753 Send a message via MSN to Prm753
@Yarvin: If you run a command like this in system(),
system("C:\\Program Files\\Cant be read\\CanUReadMe.exe");
your console will complain that
Quote:
Originally Posted by cmd.exe
C:\\Program is not recognized as an internal or external command, operable program or batch file.
because it thinks that C:\\Program is the file you are trying to open and "Files\\Cant" is the command line arguement you are trying to pass, which is not the case, obviously. The space between Program and Files is the problem. That's what they meant by System() not accepting spaces.
__________________
The world's first athletic computer geek!
The home of PrProgramsStudios
How not to post a question: <-- Please don't reply
Prm753 is offline   Reply With Quote
Old Apr 26th, 2006, 5:04 PM   #16
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5 grumpy will become famous soon enough
Personally, I don't use the system call, but my guess would be;
   system("\"C:\\Program Files\\alcohol soft\\alcohol 120\\AxCmd.exe\" E: /u");
In short, put quotes into the string around the full name of the executable but NOT around command line arguments. Or (more simply, using forward slashes)
   system("\"C:/Program Files/alcohol soft/alcohol 120/AxCmd.exe\" E: /u");
I am, of course, assuming that AxCmd.exe is in the specified directory.
grumpy is offline   Reply With Quote
Old Apr 26th, 2006, 5:13 PM   #17
Yarvin
Programmer
 
Join Date: Sep 2005
Location: Anchorage, Alaska
Posts: 37
Rep Power: 0 Yarvin is on a distinguished road
Oh! Okay I get it now.... Thank you.
so using:
System('"C:\Program Files" E: /u')
wouldn't work?
I figured it would because the autocomplete in the command prompt just surrounds it by a pair of "".
Yarvin is offline   Reply With Quote
Old Apr 26th, 2006, 5:52 PM   #18
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 893
Rep Power: 4 The Dark is on a distinguished road
Quote:
Originally Posted by Yarvin
Oh! Okay I get it now.... Thank you.
so using:
System('"C:\Program Files" E: /u')
wouldn't work?
I figured it would because the autocomplete in the command prompt just surrounds it by a pair of "".
It wouldn't compile, you can't use single quotes around strings in c++.
The Dark is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:51 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC