I hope, this is not a compiler issue. See the below code

#include <iostream>
#include <string>
using namespace std;

string data,name;
void getTst()
{
    cout<<"Enter Name :";
    getline(cin,name);
    cout<<"\nENter data :";
    getline(cin,data);
}
void dispTst()
{
cout<<"\nName :"<<name;
    cout<<"\n Data :"<<data;
}
int main()
{
    int tmp;
    cin>>tmp;

    getTst();
    dispTst();
}

in this code, before calling getTst() function I'm reading the value for tmp.In runtime, I gave the input to "tmp" and pressed ENTER. so ascii value of ENTER is stored in the "name" variable and cursor is waiting to get input for "data".

You are mixing input types. After your call to cin >> tmp you need to clear the input buffer. You can use cin.ignore() for this. If that does not work narue has a good sticky thread on how to clear the input buffer that is very informative

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.