C++ 连接后,不显示第一个字母

C++ 连接后,不显示第一个字母,c++,concatenation,C++,Concatenation,下面是代码,我让这个程序连接两个字符串连接,但在显示中连接后,它不会显示第一个单词…我认为cin中缺少一些东西。ignore()请检查并帮助我 #include "stdafx.h" #include<iostream> #include <stdio.h> #include <string> #define MAX 100 using namespace std; void main () { char str[MAX],abc[MAX]; cout<

下面是代码,我让这个程序连接两个字符串连接,但在显示中连接后,它不会显示第一个单词…我认为cin中缺少一些东西。ignore()请检查并帮助我

#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");

}
#包括“stdafx.h”
#包括
#包括
#包括
#定义最大值100
使用名称空间std;
空干管()
{
字符str[MAX],abc[MAX];

问题出在“.ignore()”上当用户点击输入时,他试图抓住新行,可能是因为,但是如果是这样,他就乱了。当然,从我写了任何C++以来,已经15年了,所以我可以关闭,但是我想是这样。但是当我不使用Cin时,忽略它也给出了我的错误。使用this@Niazi-正如Eric所说,您应该使用
ignore
get
之后而不是之前跳过换行符。