Below is the code given i have made this program to concatenate two strings concatenation but after concatenation in display it doesnot displays the first word…..i think there is some thing missing in cin.ignore() kindly check and help me????
#include "stdafx.h"
#include<iostream>
#include <stdio.h>
#include <string>
#define MAX 100
using namespace std;
void main ()
{
char str[MAX],abc[MAX];
cout<<"\nEnter the string 1";
cin.ignore();
cin.get(str,MAX);
cout<<"\nEnter The String 2";
cin.ignore();
cin.get(abc,MAX);
cout<<"\nS1="<<str;
cout<<"\ns2="<<abc;
strcat(str,abc);
cout<<"\nStrings after catenation are"<<str;
system("pause");
}
Errors in this program are that after concatenation first letter is not displayed on this line cin.ignore();. Another error is that I want to store result in another char say char d[MAX] but compiler gives error
The problem is the “.ignore()”, which ignores the next character input by the user. Why are you using this?