I ran into a bug on my program that I couldn't find on my own so I decided to transfer my project from Dev C++ to Microsoft Visual Studio.

In Dev I got away with

string sName;
cin >> sName;

But MVS doesn't like doing that. What is the substitute for comparing and saving user inputed strings?

Also:

srand(time(0));

was what I used to grab the internal clock to create random numbers, but in visual studio, it doesn't recognize that command.

Any help is greatly appreciated

To use the srand function with time(0) you must include <ctime>. 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.

Maybe the problem is in the include you need to add (#include <string>)

#include <string>
#include <iostream>

using namespace std ;

int main()
{
 string sName;
 cin >> sName;
 return 0;
}

Maybe the problem is in the include you need to add (#include <string>)

#include <string>
#include <iostream>

using namespace std ;

int main()
{
 string sName;
 cin >> sName;
 return 0;
}

Ahh, I never knew you could do that :P

Thanks!

<ctime> and <string> were what was missing from my code. Dev C++ let me skip those for some reason.

>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.

This article has been dead for over six months. Start a new discussion instead.