Arrays in C are classified into one-dimensional, two-dimensional, and multi-dimensional arrays.
No. "Two" is "multi". "Multi" means more than one, not more than two. So there are only one- and multi-dimensional arrays. But even that's wrong. All arrays in C are one-dimensional. What you call "multi-dimensional" is really just a one-dimensional array of a type that just so happens to be another array. It's not a special case.
In static uninitialized arrays, all the elements initially contain garbage values ...
No. If an array is declared static, then, if not explicitly initialized, they're initialized to 0 (or equivalent); hence, there's no such thing as a "static uninitialized array." The same is true for any array (static or not) declared at file scope. Only non-static arrays local to a function or as a member of a struct are not initialized.
printf("%d", nums[-1]); //Garbage value will be printed
At best; or your program will crash.
You never mention that you can omit the array size:
int x[] = { 0, 1, 2 }; // compiler will deduce size of 3
You never mention that you can copy arrays using memcpy(). You also never mention that arrays are copied implicitly if they're part of a struct:
struct S {
int x[3];
};
struct S a, b;
// ...
a = b; // b::x _is_ copied to a::x
You mention multi-dimensional arrays, but never discuss them.
You don't cover the odd case of passing "arrays" as function parameters.
No. "Two" is "multi". "Multi" means more than one, not more than two. So there are only one- and multi-dimensional arrays. But even that's wrong. All arrays in C are one-dimensional. What you call "multi-dimensional" is really just a one-dimensional array of a type that just so happens to be another array. It's not a special case.
No. If an array is declared
static, then, if not explicitly initialized, they're initialized to 0 (or equivalent); hence, there's no such thing as a "static uninitialized array." The same is true for any array (staticor not) declared at file scope. Only non-staticarrays local to a function or as a member of astructare not initialized.At best; or your program will crash.
You never mention that you can omit the array size:
You never mention that you can copy arrays using
memcpy(). You also never mention that arrays are copied implicitly if they're part of astruct:You mention multi-dimensional arrays, but never discuss them.
You don't cover the odd case of passing "arrays" as function parameters.
Thanks @pauljlucas for the correction ♥