electroRF
Member
Hi,
I read that to declare an array in C, one needs to specify the type of the elements and the number of elements required by an array as follows:
type arrayName [ arraySize ];
However, I see many times the following:
int[] arr;
or
int[][] arr;
How come these are valid?
I tried it myself and it resulted in an error.
I also tried it inside function's argument, and also got an error.
(working with DEV-C++).
Thank you for any help.
---EDIT---
I'd appreciate it if you could also comment on the following:
when declaring a pointer:
char *p;
it points on a garbage.
But when declaring + initializing a pointer:
char *p = "text";
does it allocate 5 bytes in memory for p? (text + '\0' are 5 bytes)
I read that to declare an array in C, one needs to specify the type of the elements and the number of elements required by an array as follows:
type arrayName [ arraySize ];
However, I see many times the following:
int[] arr;
or
int[][] arr;
How come these are valid?
I tried it myself and it resulted in an error.
I also tried it inside function's argument, and also got an error.
(working with DEV-C++).
Thank you for any help.
---EDIT---
I'd appreciate it if you could also comment on the following:
when declaring a pointer:
char *p;
it points on a garbage.
But when declaring + initializing a pointer:
char *p = "text";
does it allocate 5 bytes in memory for p? (text + '\0' are 5 bytes)
Last edited: