char array[] = "string";
or
char array[10] = "string";
what's the difference in C and which is a better way?
Since both works then why limiting the array by putting a value inside the []
Never mind, thanks
char array[] = "string";
or
char array[10] = "string";
what's the difference in C and which is a better way?
Since both works then why limiting the array by putting a value inside the []
Never mind, thanks
what's the difference in C and which is a better way?
char array[]="string";
declares array
as an array of 7
char
s and initialize it with string
.
char array[10]="string";
declares array
as an array of 10
char
s and initialize it with string
.
You can use either depending as per the requirements. For ex: If you go with first, then string concatenation is not possible. If you go with second then a string of length 3
(including '\0'
) can be concatenated to it.