Discuss Scratch

JAVAProgramming
Scratcher
100+ posts

C++ Not Working

Hey,
I'm using Microsoft Visual Studio 2013 and none of the code has syntax highlighting (which is annoying and I would like to fix). Code can be found here: http://pastebin.com/9yuZy0W6

I'm also getting an error:
Error 1 error C2679: binary ‘>>’ : no operator found which takes a right-hand operand of type ‘std::string’ (or there is no acceptable conversion)

As far as I'm concerned, cin operates with >> following (just as cout has << after it).

As you can see, I'm a little confused. If you can help in any way, please do.

Thanks
JAVAProgramming

Last edited by JAVAProgramming (July 26, 2014 18:49:10)

astro-mechanic
Scratcher
500+ posts

C++ Not Working

Why not use getline(cin, userInput)?
Chainmanner
Scratcher
100+ posts

C++ Not Working

If I understand it right, that's a right-shift binary operation, right? If so, then it can't be used on strings, if I'm right.
astro-mechanic
Scratcher
500+ posts

C++ Not Working

Chainmanner wrote:

If I understand it right, that's a right-shift binary operation, right? If so, then it can't be used on strings, if I'm right.
That's the error it's giving, but it's actually supposed to be a stream operator in this case…
JAVAProgramming
Scratcher
100+ posts

C++ Not Working

Chainmanner wrote:

If I understand it right, that's a right-shift binary operation, right? If so, then it can't be used on strings, if I'm right.
I've used it before and it's been fine..
JAVAProgramming
Scratcher
100+ posts

C++ Not Working

astro-mechanic wrote:

Why not use getline(cin, userInput)?
I just tried that, and I'm getting: error C3861: ‘getLine’: identifier not found

Do I need to include any other libraries?
astro-mechanic
Scratcher
500+ posts

C++ Not Working

JAVAProgramming wrote:

astro-mechanic wrote:

Why not use getline(cin, userInput)?
I just tried that, and I'm getting: error C3861: ‘getLine’: identifier not found

Do I need to include any other libraries?
Nope…isn't C++ case sensitive?

Last edited by astro-mechanic (July 26, 2014 19:56:59)

MegaApuTurkUltra
Scratcher
1000+ posts

C++ Not Working

Visual Studio is really annoying. You should use Eclipse CDT and MinGW.
selimi02
Scratcher
70 posts

C++ Not Working

Did you #include <string> ?
peterkap
Scratcher
100+ posts

C++ Not Working

Weird… Hmm, my C++ is a really really rusty, so not sure.
I believe you need
#include <string>

Good luck.
turkey3
Scratcher
1000+ posts

C++ Not Working

MegaApuTurkUltra wrote:

Visual Studio is really annoying. You should use Eclipse CDT and MinGW.
Visual Studio is not annoying at all. It just takes some getting used to.
peterkap
Scratcher
100+ posts

C++ Not Working

turkey3 wrote:

MegaApuTurkUltra wrote:

Visual Studio is really annoying. You should use Eclipse CDT and MinGW.
Visual Studio is not annoying at all. It just takes some getting used to.
Visual Studio is the best IDE especially for .NET programming languages since it is developed by Microsoft, so of course Visual Studio will always be the IDE that's updated first, and the best choice.

Last edited by peterkap (July 27, 2014 01:45:08)

Znapi
Scratcher
500+ posts

C++ Not Working

You need to include the string header to use the data type “string”, which is also why getline() wont work.

Powered by DjangoBB