First problem, your second argument to scanf should be just z instead of &z.
Second, don't use scanf() to read user input from stdin. Use fgets() instead.
fgets will properly check for buffer overflow and also read until enter key pressed and process spaces properly.
Code:
char z[256];
fgets(z,sizeof(z),stdin);