Learn C in Y Minutes
learnxinyminutes.com
Learn C in Y Minutes
1–10 of 81 posts
Re: Learn C in Y Minutes
#2Re: Learn C in Y Minutes
#3The author recommends -std=c99 (-pedantic) default flags, yet suggests K&R (2nd edition, presumably) as a reference...
Re: Learn C in Y Minutes
#4The author recommends -std=c99 (-pedantic) default flags, yet suggests K&R (2nd edition, presumably) as a reference...
Little reason to not use at least -std=c11 these days
Re: Learn C in Y Minutes
#5At least these are not uninitialised variables.
// Shorthands for multiple declarations:
int i1 = 1, i2 = 2;
float f1 = 1.0, f2 = 2.0;
int b, c;
b = c = 0;
Edited:..
After 1hr of posting my original comment, I noticed that there many opinions here.I should have added why I think this is bad. Readability and maintenance. I would rather it have one line per declaration like the following..
int i1=2;
int i2=2;
Each variable easier to be changed, and reading it is clearer as there are no ambiguity to its type.A common error I have see from "the multiple declarations in the single line" construct is that changing the type impacts all the variables whereas the intention was only for the first variable.
Re: Learn C in Y Minutes
#6Re: Learn C in Y Minutes
#7The author recommends -std=c99 (-pedantic) default flags, yet suggests K&R (2nd edition, presumably) as a reference...
Re: Learn C in Y Minutes
#8Oh man, multiple declaration on the single of code is nasty. Passing this kind of advice causes the beginners to develop bad habits. At least these are not uninitialised variables. // Shorthands for multiple declarations: int i1 = 1, i2 = 2; float f1 = 1.0, f2 = 2.0; int b, c; b = c = 0; Edited:.. After 1hr of posting my original comment, I noticed that there many opinions here. I should have added why I think this i…
void function_1();
Most people coming from other languages (like C++) will probably think that this is identical with "void function_1(void)", but without the explicit void argument list, the compiler will not warn if the function is accidentally called with parameters.Re: Learn C in Y Minutes
#9Oh man, multiple declaration on the single of code is nasty. Passing this kind of advice causes the beginners to develop bad habits. At least these are not uninitialised variables. // Shorthands for multiple declarations: int i1 = 1, i2 = 2; float f1 = 1.0, f2 = 2.0; int b, c; b = c = 0; Edited:.. After 1hr of posting my original comment, I noticed that there many opinions here. I should have added why I think this i…
Re: Learn C in Y Minutes
#10The author recommends -std=c99 (-pedantic) default flags, yet suggests K&R (2nd edition, presumably) as a reference...
Little reason to not use at least -std=c11 these days
https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-...
(it has a solid subset of C99 since around VS2015 though, just _Generic was missing - and ignoring VLAs, which have been "dropped" in later C standards anyway).