I am attempting to fill in values for a matrix and I am using cin to input number types such as int or float one at a time. Unfortunately, when I try to input numbers into a large matrix, usually larger than 4 by 4, it is harder to visualize the matrix when after each input, a new line is generated . How can I prevent a new line from being generated after a cin so I can then use spaces or '\t' to indicate another cin.

Any help appreciated.

Hi JasonV,

cin will automaticly seperate by whitespace. That includes carrige returns, tabs regular spaces and vertical tabs (which are hardly ever used). So if you read in 4 numbers in you code and the input has seperated some of those 4 numbers with carrige returns, then it doesn't matter, all 4 will be read.

What you need to do is detect if you have reached the end of the matrix. You could just read in numbers till the stream closes. You could use peek() to determine if there is something other than a number. There are probably other ways to do this too. The way you do it is up to you.

Hope this helps.

Adrian