I'm so used to typing
for (int i = 0; i < n; ++i) { ... }
in C++ that it's a pain to use a non-C99 compiler where I am forced to say
int i;
for (i = 0; i < n; ++i ) { ... }
stdint.h
, which defines int8_t
, uint8_t
, etc. No more having to make non-portable assumptions about how wide your integers are.
uint32_t truth = 0xDECAFBAD;
I think that the new initializer mechanisms are extremely important.
struct { int x, y; } a[10] = { [3] = { .y = 12, .x = 1 } };
OK - not a compelling example, but the notation is accurate. You can initialize specific elements of an array, and specific members of a structure.
Maybe a better example would be this - though I'd admit it isn't hugely compelling:
enum { Iron = 26, Aluminium = 13, Beryllium = 4, ... };
const char *element_names[] =
{
[Iron] = "Iron",
[Aluminium] = "Aluminium",
[Beryllium] = "Beryllium",
...
};
Support for one-line comments beginning with //
.
Variable length arrays:
int x;
scanf("%d", &x);
int a[x];
for (int i = 0; i < x; ++i)
a[i] = i * i;
for (int i = 0; i < x; ++i)
printf("%d\n", a[i]);
Being able to declare variables at locations other than the start of a block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With