Liste des Groupes | Revenir à cl c |
Back in the days of K&R, Kernighan and Ritchie published an addendumI use these features regularly. I have no problem passing structs around if that is the convenient way to structure the code.
to the "C Reference Manual" titled "Recent Changes to C" (November 1978)
in which they detailed some differences in the C language post "The
C Programming Language".
The first difference they noted was that
"Structures may be assigned, passed as arguments to functions, and
returned by functions."
From what I can see of the ISO C standards, the current C language
has kept these these features. However, I don't see many C projects
using them.
I have a project in which these capabilities might come in handy; hasI'd immediately reject any code that mixes declaration of a variable and a function in the same declaration. I'd immediately reject any code that defines a type and declares a function in one shot. I'd question code that defines a type and a variable in one go. But that's my way of coding - other people have different rules, and your declarations are legal.
anyone had experience with assigning to structures, passing them as
arguments to functions, and/or having a function return a structure?
Would code like
struct ab {
int a;
char *b;
} result, function(void);
if ((result = function()).a == 10) puts(result.b);
be understandable, or even legal?
Les messages affichés proviennent d'usenet.