Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!ADLER1%BRANDEIS.BITNET@wiscvm.wisc.EDU From: ADLER1%BRANDEIS.BITNET@wiscvm.wisc.EDU Newsgroups: comp.lang.c Subject: *\"LDA\" ok? Message-ID: <8877@brl-adm.ARPA> Date: Wed, 19-Aug-87 23:55:11 EDT Article-I.D.: brl-adm.8877 Posted: Wed Aug 19 23:55:11 1987 Date-Received: Sat, 22-Aug-87 06:30:32 EDT Sender: news@brl-adm.ARPA Lines: 27 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? #include main() { char opcode[4]; int address, index, left, right ; printf("Type assembly language statement:\n\n"); scanf("%s %d,%d(%d:%d)",opcode, &address, &index, &left, &right); printf("Opcode\t=%s\n",opcode); printf("Address\t=%d\n",address); printf("Index\t=%d\n",index); printf("Field\t= (%d:%d)\n",left,right); if (*opcode == *"LDA") printf("Gotcha!\n"); else printf("No match...\n"); } ADLER1@BRANDEIS.BITNET