0

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

5
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by Narue
0

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.

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;
}
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

0

Thanks!

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

0

>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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.