Sujet : Re: Suggested method for returning a string from a C program?
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 20. Mar 2025, 14:06:37
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86ecyronqa.fsf@linuxsc.com>
References : 1 2 3 4 5 6
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Richard Heathfield <
rjh@cpax.org.uk> writes:
On 19/03/2025 05:02, DFS wrote:
>
On 3/19/2025 12:51 AM, Richard Heathfield wrote:
>
On 19/03/2025 04:42, DFS wrote:
>
Pretty easy fixes:
>
1 use scanf()
2 update int to long
3 handle special case of n = 1
4 instead of collecting the results in a char variable, I print
them as they're calculated
>
You've also fixed another glitch which may or may not have been
significant:
>
$ file post2.txt
post2.txt: news, ASCII text
>
So wherever that UTF-8 came from, it's gone now.
>
Cool. Thanks for looking at it.
>
Hey, how are your C book (from 2000) sales? Thought about a new
edition?
>
I'm not sure a new edition is necessary, but if it is to be
written it would be better served by someone like Keith or Tim,
both of whom have (as I have not) kept up with the million-and-one
changes that appear to have assailed the simple language I once
enjoyed.
The C99 standard has a list of 54 what it calls "major changes",
although IMO many or most of those are fairly minor. There are also
other differences relative to C90, but most of them are simply
clarifications or slight changes in wording.
I went through the list of major changes and selected out the items
I consider the most significant. Here they are, organized into
several related areas.
Language constructs taken out from C90:
REMOVED: implicit int
REMOVED: implicit function declaration
Comments:
// comments are now allowed
Preprocessor:
empty macro arguments
macros with variable number of arguments
Lexical:
improved lower bounds for identifier length -
went from 6 and 31 (for global and non-global) in C90
to 31 and 63 in C99
Types added:
boolean type _Bool
complex numbers
long long and unsigned long long
New language constructs:
more general initialization for aggregates and unions
compound literals
designated initializers
mixing of declarations and code (including in for() initializers)
Array related:
arrays and array types with non-constant extents, aka
VLA, for variable length arrays, and
VMT, for variably modified type
flexible array members (recognizing the "struct hack")
Miscellaneous:
'inline' functions
return with expression now disallowed in void function,
and vice versa
I included the "array related" items, and also complex numbers, as
significant items, even though they aren't used very often. I think
it's important to know about these features, despite their
infrequent use. (Incidentally, both complex numbers and VLA/VMT
were made optional in C11.)