String program problem

The program asks the user to enter his or her first name and then last name, and
that then constructs, stores, and displays a third string consisting of the user’s last name, followed by a comma, a space, and first name. I'm using string objects and methods from the string header file.

But it issues the following error during the compilation:

1>------ Build started: Project: ex4ch4, Configuration: Debug Win32 ------
1>Compiling...
1>source.cpp
1>c:\documents and settings\user\my documents\visual studio 2008\projects\bacon\bacon\source.cpp(14) : error C2664: 'strcpy' : cannot convert parameter 1 from 'std::string *' to 'char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\user\my documents\visual studio 2008\projects\bacon\bacon\source.cpp(15) : error C2664: 'strcat' : cannot convert parameter 1 from 'std::string *' to 'char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\user\my documents\visual studio 2008\projects\bacon\bacon\source.cpp(16) : error C2664: 'strcat' : cannot convert parameter 1 from 'std::string *' to 'char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Build log was saved at "file://c:\Documents and Settings\User\My Documents\Visual Studio 2008\Projects\bacon\bacon\Debug\BuildLog.htm"
1>bacon - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


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

int main()
{
	using namespace std;
	string firstName;
	string lastName;
	cout << "Enter your first name: ";
	getline(cin, firstName);
	cout << "Enter your last name: ";
	getline(cin, lastName);
	string * fullName = new string;
	strcpy(fullName, lastName);
	strcat(fullName, ", ");
	strcat(fullName, firstName);
	cout << "Here's the information in a single string: " << fullName << endl;
	system("pause");
	return 0;
}


What's up with that?
Do you really need to use a new string?
It works if you just use a regular string for fullName;
Don't use strcpy and strcat they are meant for char*.
Use the std::string operators = and + instead.
And bluezor is right don't create a new string.
Topic archived. No new replies allowed.