sizeof(parr) is NOT the amount of allocated space, it is the size of char* (parr's datatype). The only portable way to know the amount of memory you have allocated is to keep track of it yourself.
Assuming that realloc is working as expected, the amount of bytes you have allocated will be equal to your variable size.
Just a few other things I noticed in your code:
char* parr = malloc(sizeof(char));
You should always check the return value of malloc to ensure that it succeeded:
char* parr; if(!(par = malloc(sizeof(char))) { //allocation failed }
The next part of your code that caught my eye:
int size = sizeof(char)*len;
This is actually not needed. sizeof(char) is always equal to one byte, so you might as well just use the current value of len instead of declaring a new variable which is equal to len * 1 on each iteration of your loop.
parr = (char *) realloc(parr,size);
As mentioned earlier you don't need to use size since it is equivelent to len. Also in C it is generally not a good idea to cast your pointers, you should also check the return value of realloc incase it fails:
if(!(parr = realloc(parr, size))) { //allocation failed }
As a last note I always use a buffer when using the realloc function to avoid potential memory issues. Here is my spin on your code:
char *readChar(void) { int c, len = 0; char* parr = NULL, char *tmp; if(!(parr = malloc(sizeof(char))) { fputs("memory allocation failed", stderr); exit(1); } while((c = getchar()) != EOF) { ++len; if(!(tmp = realloc(parr, len))) { free(parr); fputs("memory allocation failed", stderr); exit(1); } parr = tmp; *(parr+len-1) = (char) c; } return parr; }