you must define the variable Name as "string" not "char" and add
#include <string>.
Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard
icujc wrote:Tronn wrote:Shouldn't that be <cstring> ?
Nope he had it right. You could also just make this a char array like this:
char Name[15];
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
string name;
cout << "Please enter your name: ";
cin >> name;
cout << "\nHello " << name;
return 0;
}
Code:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
string name;
cout << "Please enter your name: ";
cin >> name;
cout << "\nHello " << name;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout << "Please enter your name: ";
cin >> name;
cout << "\nHello " << name;
return 0;
}
Tronn wrote:So they both work then.
Tronn wrote:Hmmm. Strange. cstring worked fine for me.
I'm using Borland 5.5.1 compiler.
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
string name;
cout << "Please enter your name: ";
cin >> name;
cout << "\nHello " << name;
return 0;
}
Users browsing this forum: No registered users and 2 guests