OpenWatcom and getline()

Hi.

I'm completely new to C++, and due to my job, I need to start learning it.
I decided to use OpenWatcom under Windows 10 (if there is a better lightweight alternative, I'm open to suggestions).

I am now in the "basic input/output" part of the tutorial hosted in this same website.

I tried to compile a piece of code as simple as this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// cin with strings
#include <iostream>
#include <string>
using namespace std;

int main ()
{
  string mystr;
  cout << "What's your name? ";
  getline (cin, mystr);
  cout << "Hello " << mystr << ".\n";
  cout << "What is your favorite team? ";
  getline (cin, mystr);
  cout << "I like " << mystr << " too!\n";
  return 0;
}



But the compiler returns me a "symbol 'getline' has not been declared".

In fact, that piece of code is a literal copy-paste from the tutorials in this website.

But when I run that code on http://cpp.sh, it works fine, what leads me to think that OpenWatcom doesn't follow a standard C++ or declaration of symbols doesn't follow the expected standards.

Any advice?

Thanks beforehand.
Last edited on
Including <string> certainly should get you getline, so...

[...] what leads me to think that OpenWatcom doesn't follow a standard C++ or declaration of symbols doesn't follow the expected standards.


That's entirely possible. I've never heard of OpenWatcom, so I'm guessing it's quite an obscure and little-used compiler. The Wiki page says that the last official release was 2010, so you're certainly not going to get support for the modern standards (C++11, C++14, C++17).

Any advice?


I know it's a pain, but I'd suggest switching to a modern, well-used and well-supported compiler and IDE. I always used MS Visual Studio on Windows, but I'm sure others here will have their own recommendations.
Last edited on
I second the suggestion to switch compilers and IDE. OpenWatcom is very outdated, it appears to support only a few C++11 features. I also doesn't truly support any of the C++ standards.

Thank you for your suggestions.

We end up giving a try to Dev-C++.
Topic archived. No new replies allowed.