TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: BRIAN WOOD
date: 1998-01-21 11:44:00
subject: `/a`=?

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.