0

I'm a complete noob at C++, and the first problem I am encountering is the following:

no operator >> matches these operands

#include "pch.h"
#include <iostream>
#include <string>

using namespace std;

int main()
{
    cout << "hello world!";
    cin >> "hello world!";
}
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
sfsdf AAFF
  • 11
  • 2

1 Answers1

6

std::cin needs to write to a variable, but you are passing it a const char[13] string literal instead.

You need to pass it something like a std::string instead:

std::string str;
std::cin >> str;

P.S. This is a good time to a) read compiler messages, b) avoid using namespace std; globally, c) get a good C++ book.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Michael Chourdakis
  • 10,345
  • 3
  • 42
  • 78