String problems

Hey I'm trying to setup message for my project but i'm getting the error message:

IntelliSense: no operator "=" matches these operands
operand types are: std::string = std::basic_istream<char, std::char_traits<char>>

I'm not sure what its asking for.

here's the code for my error message:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
string input;

do
{
gotoXY(8, 8); cout << "Title:   "; 
	gotoXY(12, 8); cin >> input; 
	if (input.size() > 40)
	{
		message("Error! please enter title between 2 to 40 characters", 12, 9);
	}
	else
		input = cin >> dvds[size].title;
	} while (cin && input.size() > 40);



Any help would be appreciated

read your dvd title into a string first, and then assign to dvds[size].title

edit: it looks like you're cin'ing twice. dont do this. i'd use getline to read in the string to be honest.
http://www.cplusplus.com/reference/string/string/getline/
Last edited on
Ok Thanks for your help :)
well, variable input is of type string

but the return from "cin >> x" is a reference to an input stream

line 12 reads a value from the input stream object cin, into the variable dvds[size].title, and returns a reference to the input stream object cin

In line 12, you're trying to assign this (input stream object) to a string - there's no operator= defined that would do that
Topic archived. No new replies allowed.