Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ames!lll-tis!ptsfa!hoptoad!academ!uhnix1!sugar!splut!jay From: jay@splut.UUCP (Jay Maynard) Newsgroups: comp.lang.c Subject: Re: *\"LDA\" ok? Message-ID: <87@splut.UUCP> Date: Mon, 24-Aug-87 07:36:11 EDT Article-I.D.: splut.87 Posted: Mon Aug 24 07:36:11 1987 Date-Received: Fri, 28-Aug-87 01:44:13 EDT References: <8877@brl-adm.ARPA> <8088@mimsy.UUCP> Organization: Confederate Microsystems, League City, TX Lines: 40 Summary: C doesn't speak strings. In article <8088@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: > In article <8877@brl-adm.ARPA> ADLER1%BRANDEIS.BITNET@wiscvm.wisc.EDU writes: > >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.... > > if (*opcode == *"LDA") printf("Gotcha!\n"); > > else printf("No match...\n"); [description of learning process deleted] > Eventually it seems to dawn upon these programmers that > > "LDA" > > generates an anonymous character array holding the letters L, D, > A, and NUL (\0) and evaluates to the address of this array. Then > the purpose of strcmp() becomes clear, and they live happily ever > after :-). > > All I want to know is this: Why does it take so long for some > programmers to see this, and how can we speed up the process? Because most other languages, and all of the other languages that a programmer new to C is likely to know, handle strings intrinsically. C is the only major language that doesn't know itself what to do with strings, but instead forces programmers to kludge around with pointers and function calls instead of allowing precisely the construct described above. This is the source of most of C's crypticness (crypticity? naaaaaah.) to the inexperienced programmer. About the only way I can think of to speed up the process is to add string intrinsics to C. (asbestos suit on) -- Jay Maynard, K5ZC...>splut!< | uucp: hoptoad!academ!uhnix1!nuchat!splut!jay "Don't ask ME about Unix... | (or sun!housun!nuchat) CI$: 71036,1603 I speak SNA!" | internet: beats me GEnie: JAYMAYNARD The opinions herein are shared by neither of my cats, much less anyone else.