私は C++ の初心者で、MSDN C++ ビギナーズ ガイドから学んでいます。
strcat 関数を試してみると機能しますが、最初に奇妙な文字が 3 つ表示されます。
これが私のコードです
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
char first_name[40],last_name[40],full_name[80],space[1];
space[0] = ' ';
cout << "Enter your first name: ";
gets(first_name);
cout << "Enter your last name: ";
gets(last_name);
strcat(full_name,first_name);
strcat(full_name,space);
strcat(full_name,last_name);
cout << "Your name is: " << full_name;
return 0;
}
そして、ここに出力があります
Enter your first name: Taher
Enter your last name: Abouzeid
Your name is: Y}@Taher Abouzeid
なぜ私の名前の前に Y}@ が付くのだろうか?