Expression must be a modifiable Ivalue?

I am trying to put the data in buffer into sbuffer.Message. However, sbuffer is underlined red and says expression must be a modifiable Ivalue.

Here is the relevant code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
struct Buffer
{
	int ID;
	char Message[256];
};

//in main
			Buffer sbuffer;
			sf::Packet sPacket;

			char* buffer = new char[256];
			std::cin >> buffer;
			getchar();

			sbuffer.ID = ID;
			sbuffer.Message = buffer;

			if( socket.send(&sbuffer, sizeof(buffer)+1) == sf::Socket::Done)
				std::cout<<"Sending Message: "<<buffer<<std::endl;
Last edited on
You can't use the assignment operator with C-strings. You will need to use strcpy().

Thanks you!
Topic archived. No new replies allowed.