Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!aurora!labrea!decwrl!sun!pitstop!texsun!convex!trsvax!authorplaceholder From: billc@trsvax.UUCP Newsgroups: comp.lang.c Subject: Re: *\"LDA\" ok? Message-ID: <192800005@trsvax> Date: Mon, 24-Aug-87 18:36:00 EDT Article-I.D.: trsvax.192800005 Posted: Mon Aug 24 18:36:00 1987 Date-Received: Sat, 19-Sep-87 11:37:36 EDT References: <8877@brl-adm.ARPA> Lines: 19 Nf-ID: #R:brl-adm.ARPA:-887700:trsvax:192800005:000:789 Nf-From: trsvax.UUCP!billc Aug 24 17:36:00 1987 >/* Written 10:55 pm Aug 19, 1987 by wiscvm.wisc.EDU!ADLER1%BRANDEIS.*/ >/* ---------- "*\"LDA\" ok?" ---------- */ >I was trying to write a C program that would read MIX commands from >stdin. I also wanted to be able to verify that the string opcode >was actually internally equal to the string LDA in case the MIX >command was LDA 2000,2(0:3) . After some experimentation I >arrived at the following code. It works, but I am somewhat dismayed >by the expression (*opcode == *"LDA") . It just looks so peculiar. >Is it really OK? NO!!! What you're doing here is simply comparing the first character from each string. Instead, use something like this: strupr (opcode); /* convert any lower case chars to upper case */ if (! strcmp (opcode, "LDA")) printf ("Got match.\n");