From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f868292008c639ce X-Google-Attributes: gid103376,public From: Keith Thompson Subject: Re: C vs. Ada - strings Date: 2000/05/03 Message-ID: #1/1 X-Deja-AN: 618969441 Sender: kst@king.cts.com References: <390F0D93.F835FAD9@ftw.rsc.raytheon.com> <8en5o9$ihe$1@nnrp1.deja.com> <8eonos$e70$1@wanadoo.fr> X-Trace: thoth.cts.com 957406968 35564 205.163.0.22 (4 May 2000 02:22:48 GMT) Organization: CTS Network Services Newsgroups: comp.lang.ada X-Complaints-To: newsmaster@cts.com Date: 2000-05-03T00:00:00+00:00 List-Id: "Pascal Obry" writes: [...] > But where did you see a C string ? In C you have a pointer to a memory > space terminated by 'nul' ! > > This is not a string to me. And because C does not have strings, there is > no operator on them you have to use strcmp, strcpy, strcat, strncmp... > > Is that what a string is for C programmers :) Serious answer: yes. The C90 standard's definition of the term "string" is A string is a contiguous sequence of characters terminated by and including the first null character. A "pointer to" a string is a pointer to its initial (lowest addressed) character. The "length" of a string is the number of characters preceding the null character and its "value" is the sequence of the values of the contained characters, in order. As for the lack of built-in operators, it's certainly nice to have "=", ":=", "<", "&", and so forth, but the fact that these are implemented as function calls in C isn't really that big a deal. (In other areas, C is criticized for being too terse.) This isn't to say that C's string handling isn't flawed. Once of the biggest problems is that, though a function can return a pointer to a (variable-length) string, there's no standard way to manage the associated memory. -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> Welcome to the last year of the 20th century.