Re: Typecasting in C - getting rid of warnings
2021/03/07 16:48:35
(permalink)
Why can't arrays be returned by functions? Easy - because the C language has a single return value and while a pointer to an array is a single value, arrays are not pointers. Consider this:
void funcA(char const *text)
{
printf("Size of text: %d\n", sizeof(text)); /* text is a pointer, not an array - size = size of pointer */
}
int main()
{
char text[80]; /* text is an array */
printf("Size of text: %d\n", sizeof(text)); /* size of array is 80 bytes (well, if char = 1 byte) */
return 0;
}