* dman ([EMAIL PROTECTED]) spake thusly: > On Mon, Nov 05, 2001 at 01:17:15PM -0600, Dimitri Maziuk wrote: > | * J.A.Serralheiro ([EMAIL PROTECTED]) spake thusly: > | > so, there is no way to know in advance the length of a string unless you > | > have an identifier, or constant for it. > | > | Que? You can't know $FOO of $BAR until you take $BAR in and see what > | sort of $FOO it has. You can't know the length of a string until you > | read it in and count the characters. > > Right, but if you don't know ahead of time that the sequence of > characters is NUL terminated, how do you know when to stop counting > characters?
This is purely hypothetical: if you're scanf()'ing in in, the length is <= BUFSIZE, as I pointed out before. Only way you can get a char array of unknown size is when an external app passes you a non null-terminated char* without giving you its size. Obviously, whoever writes programs like that should be taken out and shot, this really has nothing to do with C (or any other language for that matter). > | Shroedinger's Cat (there is no "string" in C, BTW) > > That's a large part of the problem, IMO. > > This discussion supports a quote that I like : > "Don't use C; In my opinion, C is a library programming language > not an app programming language." - Owen Taylor (GTK+ developer) > > C is great of low-level, close-to-the-metal, sort of programming like > kernels, device drivers, and interpreters. However for application > development, where high-level data structures, logic, and interactions > are common a higher level language is much more appropriate and is > likely to reduce development effeort required. Yeah, yeah. When you try to write a bloated monstrosity like e.g. gnome in C, you find out there's a lot of development effort required, sure. So use Java, it has built-in facilities for writing slow and bloated code. Dima -- "Mirrors and copulation are abominable because they increase the number of entities." -- corollary to Occam's Razor