Can someone help me understand why different compilers treat this code
differently? Specifically Borland(3.0-4.52) -vs- Microsoft(8.00)
cout << "The value of /a is " << (char)'/a' << endl;
Borland will send a backslash. Microsoft, the letter a.
or without the cast:
cout << "The value of /a is " << '/a' << endl;
Borland evaluates 24879. Microsoft 12129...??
The problem has come up while dealing with command-line args in some
older code I want to reuse, and it's driving me a little nuts.
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;
}
}
Thanks!
L8r,
bw
... Everyone is entitled to my opinion.
--- Blue Wave/DOS v2.20
---------------
* Origin: River Canyon Rd. BBS Chattanooga, Tn (1:362/627)
|