You can use C++ style strings. That's unless it is a homework and you have to do it a certain way.
CODE
#include <iostream>
#include <string>
using namespace std;
int prompt();
int prompt_again();
int display();
int rc = 0;
string line;
string line2;
string line3;
int main()
{
rc = prompt();
rc = prompt_again();
rc = display();
return rc;
}
int prompt()
{
cout << "Enter A String ";
getline(cin, line);
return 0;
}
int prompt_again()
{
cout << "Enter Another String ";
getline(cin, line2);
return 0;
}
int display()
{
line3 = line + " " + line2;
cout << "\nThe New String Is: " << line3 << "\n\n";
return 0;
}
Also i don't understand why display(), prompt_again(), prompt() return a 0. I would make the functions void and eliminate some things:
CODE
#include <iostream>
#include <string>
using namespace std;
void prompt();
void prompt_again();
void display();
string line;
string line2;
string line3;
int main()
{
prompt();
prompt_again();
display();
system("PAUSE");
return 0;
}
void prompt()
{
cout << "Enter A String ";
getline(cin, line);
}
void prompt_again()
{
cout << "Enter Another String ";
getline(cin, line2);
}
void display()
{
line3 = line + " " + line2;
cout << "\nThe New String Is: " << line3 << "\n\n";
}
This post has been edited by #include<wmx010>: 2 Feb, 2008 - 10:52 AM