error C2106: '=' : left operand must be l-value

Hi guys, Can anybody help me in this kind of error?..I'm actually reading a file text and I'm trying to save the string in some variable but I cannot save it because of this error,what is the solution for this..Her is my code:

infile.getline(STRING,10,':'); // Saves the line in STRING.
tmpST.id=STRING;//(where the error occurs)
cout<<STRING<<endl; // Prints our STRING.
Last edited on
You can't use the assignment operator like that with C - style strings. If you want the variable tmpST.id to be set to the value of STRING use the function strcpy( destination , source ).

strcpy( tmpST.id, STRING ).

This will copy the contents of STRING into tempST.id

http://www.cplusplus.com/reference/clibrary/cstring/strcpy/
Topic archived. No new replies allowed.