【发布时间】:2023-03-27 05:20:02
【问题描述】:
我很困惑,在我的 C++ 编码中 请帮帮我..
#include <conio.h>
#include <string.h>
#include <iostream.h>
main()
{
char h1[80];
char h2[80];
char move[80];
clrscr();
cout<<"Character 1 = ";
gets(h1);
cout<<"Character 2 = ";
gets(h2);
strcpy(move, h1);
cout<<"Result = "<<move;
getch();
}
我想要像这样的输出/结果程序
Move = h1+h2;
【问题讨论】:
-
将
std::string用于h1和move,然后使用move = h1 + h2;。 -
你用的是什么编译器?请不要说它是古老的 Turbo C++。
-
永远不要使用
gets()。这是一个安全漏洞。使用fgets()或其他东西。 -
为什么要混合 C 和 C++?
-
@PaulMcKenzie 一旦你在预处理器列表中看到
#include <iostream.h>,我认为这并不重要。这很简单ugh。 (上升,顺便说一句)。