No compiler can do that, as its wrong...sizeof operator returns the size of the data type in bytes for example
the above code will return 1 byte as char data type in most system is of 1 byte or 8bits.
the above code will return 4 bytes as int data type in most system is of 4 byte or 32bits.
The size may differ as its for embedded system,and different system use different memory size for their basic data types.
The point is that sizeof operator will return memory size of the data type.For a char pointer in your case it will return the memory size of the char pointer not the size of the array which its pointing to.If you want to send the size of your array to a function you have to pass it as an argument to the function.But first know this if you use sizeof operator with array it will return you the full memory size not how many element is in their for example if you have a array of int of size 10 like this
Code:
int i[10] = {0,1,2,3,4,5,6,7,8};
sizeof(i);
the sizeof operator will return 10 * 4 = 40 as each int data type is of 4 bytes,so to find the number of elements of the array you can do this
Code:
int i[10] = {0,1,2,3,4,5,6,7,8};
int num = sizeof(i)/sizeof(int);
OR
int num = sizeof(i)/sizeof(i[0]);
In case of char array you dont have to do this as its 1 byte of size but if the array is for some string then remember it will have a null terminator "\n" at last so it will be also counted for example
Code:
int string[10] = "edaboard";
sizeof(string);
It will return 9 , the last char is the null terminator.
Their are also other C standard library function like strlen() to find out the length of a string i.e.. char array ,but it depends on your compiler check out its help files what C standard library function it have.
Good Luck