First off Brian,
'/a' is not valid. The differences in compilers you are see is the
ompiler
attempting to work with your mistake. Single quotes are use to surround
single characters (normal or escaped): '/', 'a', '\0', '\x0D', etc...
::> example command line:
::> C:\THISPROG.EXE /a
::> while (--argc && **argv++) {
::> // case '/a': isn't evaluated consistently
::> // Best way around this?
::> cout << "\narg entered was " << endl;
::> switch (*(int*) *argv) {
::> case '/a':
::> cout << "/a" << endl;
::> break;
::> default:
::> cout << *argv << " (unknown)" << endl;
::> break;
::> }
::> }
int parms = argc - 1;
char *ptr = argv[parms];
while (parms-- && ptr)
{
cout << "arg entered was: "
if (ptr == '/')
{
switch (++ptr)
{
case 'a':
case 'A': cout << "/a" << endl; break;
default: cout << (--ptr) << "(unknown)" << endl;
}
}
else
cout << ptr << "(unknown unswitched)" << endl;
ptr = argv[parms];
}
# Herbert Bushong harchon@centuryinter.net [TEAM OS/2]
- Blackbeard's BBS Intelec: 239:600/0
+ Fido: 1:19/19 http://www.intelec.com/software/
---
RM 1.31 2508 Greed is the Walton's having another child
---------------
* Origin: Blackbeard's BBS - Ville Platte, LA - 318-468-3385 (1:19/19)
|