To use the srand function with time(0) you must include . Where as for the first one, I think you have to use a plain char array and then convert that to type string.
It would also help if you showed the errors MSV was giving.
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
Compiler errors? Perhaps post them?
Are proper header files included? And are you using these from the std namespace ?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Maybe the problem is in the include you need to add (#include )
#include <string>
#include <iostream>
using namespace std ;
int main()
{
string sName;
cin >> sName;
return 0;
}
Ahh, I never knew you could do that :P
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
>Dev C++ let me skip those for some reason.
Now you know why it's a good idea to test your code with multiple compilers.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401