954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

From DevC++ to MVS

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

Shadoninja
Light Poster
37 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

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
 

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;
}
stewie griffin
Light Poster
35 posts since Jul 2008
Reputation Points: 64
Solved Threads: 1
 

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
Team Colleague
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
 

Thanks!

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

Shadoninja
Light Poster
37 posts since Jul 2008
Reputation Points: 10
Solved Threads: 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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You