When I want to get a string with getline function, it jumps from this statement without getting string . Because I get an integer number before it and the \n is pressed . To solving this problem I use cin >> ws before getting string with getline function . Now when I want to enter white spaces in beginning of string , this white spaces is ignored .
What can I do to solving this problem ?
Thanks ......

This is what I would do.

#include <iostream>
#include <string>

using namespace std;

int main()
	int myInt;
	string myString;
	cin >> myInt;
	cin.ignore(); //use this it ignores the last '\n' character
	getline(cin, myString);
	return 0;

I want if user entered " behi jon", it stores same in variable and not "behi jon" . I need two white space at the beginning of input . But the compiler skip it .

In the code I posted I tested what you wanted and it worked.

Oh, thanks very much . It works . Thanks ... Thanks ...

This question has already been answered. Start a new discussion instead.