Unable to read string using cin.getline()

i am unable to read string using cin.getlin() after reading integer

When you press enter after the input 1.
Then cin.getline will take enter as value. Hence showing empty value

For getting rid of this problem.Use this code
cin>>n;
cin.get(); //store enter
cin.getline(str,100);

Here cin.get() will take enter (after integer)as input and cin.getline(str,100) will take your respective string .

Hit like if u get it.

cin.getline(str,100) includes white spaces and enter

1 Like

yeah thanks man :+1::+1: