Why is it an error?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>
using namespace std;

int main()
{
	char tmp[15];
	char tmp2[15];

	cin.getline(tmp, 15);

	strcpy(tmp,tmp2);
	cout<<tmp2;


	system("pause");
	return 0;
}


i've been trying out the strcpy, why i keep on getting an error?
the syntax of strcpy is strcpy ( destination, source );. So replace strcpy(tmp,tmp2) with strcpy(tmp2,tmp);.

Avoid system("pause"), use cin.sync(); cin.ignore(); instead.
Thank you so much Guzfraba!
Topic archived. No new replies allowed.