When you cascade cin such as
cin >> var1 >> var2;
it can recognize the two values when the user presses enter or space...
Enter 2 numbers: 4 5
Enter 2 numbers: 4
when i try to put anything else in there it outputs the value weird...
eg. Enter 2 numbers: 4,5
or Enter 2 numbers: 4 t 5
why can the compiler only distinguish between spaces and return chars and why?
because operator >> sees anything other than whitespace as an input and if its not the expected type of input sets the failbit. A comma and a lower case t are both not whitespace so they will not be disregarded.
also, look into the declaration type of var1 and var2, if they are ints, the ',' and 't' will be stored as ascii.
"why can the compiler only distinguish between spaces and return chars and why?"
Create a class and define the >> operator any way you want if you're so unhappy with it.
So if the >> operator doesn't see whitespace as input then wouldn't it connect the 2 values
cin >> var1 >> var2
as one number? does it do anything when it encounters whitespace?
also when i put a char infront of a int value then output it, it is a different number. On my compiler any char infront of any number outputs to be the the same number every time. Why is this? (that eg input y45 otuputs to be eg. 6)?
Mostly likely because the program takes the ascii number associated with the character. Your best bet would be to use cin.get in combination to isdigit to achieve whatever you are trying to get to here. Unless you wish to overload the >> operator (always fun to so :D ). If you want me to demonstrate how to get numbers divided by a certain character just leave a post here and i will post some code..... Don't ask me to show you how to overload >> though... been to long since i have done that kinda stuff :p
whitespace before read item is ignored, whitespace after terminates that read.
notice how anything left over from the reading of c is left in the buffer. This is typically \n but could be any sort of crap. Knowing this you should be able to tell me why this getline call appears to fail...
char* d = new char;