What does substr do? And when

char y[256];
cin>>y;

When someone inputs a " "(space), then the things after the space wont be in the char y.

For instance I input: "Tom Z"
it only gets Tom, no Z. How do I prevent that?