Code:
y = (char *)malloc(sizeof(char)*buff_size);
When using C, avoid typecasting the return value of the malloc call. Also, sizeof(char) is guaranteed to always be 1, thus the above could be safely reduced to:
Code:
y = malloc(buff_size);
You should also free the memory you've allocated to y at the end of your program (before the return statement):
Code:
free(y);