I have written the code to get context and noun from the user. In every case there is one context and multiple nouns. I am able to get the context from the user but for the nouns the code runs the first loop with noun as an empty entity and then it works properly. I am not able to figure out why it is doing so.
Secondly i tried to declaring noun as a string the code works fine at that time but if the noun has spaces in between it just takes the first part of the noun.
1.
char context[20],n[50];
cout << "enter the context:";
cin.getline(context, sizeof(context));
string context_1(context);
if (datafile.is_open())
{
cout << "enter the number of nouns:";
cin >> number;
for (int i = 1; i <= number; i++)
{
cout << "enter the noun:";
cin.getline(n,sizeof(n));
string n_1(n);
2.
char context[20];
string n;
cout << "enter the context:";
cin.getline(context, sizeof(context));
string context_1(context);
if (datafile.is_open())
{
cout << "enter the number of nouns:";
cin >> number;
for (int i = 1; i <= number; i++)
{
cout << "enter the noun:";
cin >> n;