correct way of reading string in c++?

i was solving on question on codechef.In the given question input is a string for example :-
test case1 : full name

i used cin to read this input.But “cin” will take “full” not the “full name”
now to make sure it read full sentence with i have to getline(cin,str);

now in given link http://www.codechef.com/wiki/faq#How_should_I_test_my_program
it say to test your code using following way :-
test.exe < in.txt > out.txt

now when i use cin>>str; in my code to read string with space , strangely it taking input a whole i.e with spaces.

so how should i read string with space …because simple using cin is also working.

//