manipulate map items, L-value Error

Hey Ho...

Its my first time using the map-container... and somehow i am not able to change the value of the mapped structureO_o...

i got:

1
2
3
4
5
6
7
8
struct MYSTRUCKT
{
...
char name[31];
};
map<int,MYSTRUCKT> mappy;

char NewName[31] = "somename"


but when i try one of the following:
1
2
3
4
5
6
7
8
9
mappy[number].name = NewName;

or

mappy.find(number)->second.name = NewName;

or Via an iterator

or via strcpy();



it always gives me an Error that "= left value hast to be an L-Value"

im running nuts-.-'...

greetz,
Inc
This has nothing to do with map.

You cannot assign C-style strings (char arrays) with the = operator. Use std::string instead.

1
2
3
4
5
struct MYSTRUCKT
{
  ...
  std::string name;
};
struct MYSTRUCKT
{
string name;
};

int main(){
int number=1;
MYSTRUCKT m;
map<int,MYSTRUCKT> mappy;
string NewName = "somename";

m.name = NewName;
mappy[number] = m;
}
Topic archived. No new replies allowed.