Question:
I am just beginning to learn C++ and I’ve stumble on an error that I cannot figure out despite all my efforts. Here is the code where I’m having trouble with. Thank you for any help that you can provide.
//a sub function to sort a global arrayvoid sortArray(phoneAddress info[]){ //declare variables char lastName[25] = ""; char swap ='Y'; while (swap ='Y') { swap ='N'; for (short x = 0; x < 6; x++) { if (stricmp(info[x].nameL, info[x + 1].nameL)==-1) { swap ='Y'; lastName = info[x].nameL;// error info[x].nameL = info[x+1].nameL;// error info[x+1].nameL = lastName;// error } //end if } //end for } //end while for (short x = 0; x < 6; x++) // sub function displayInfo(info, x);} // end function
Error Message on all 3 is this: "'=':left operand must be I-value."
Answer:
You cannot assign a C-string using operator =. Instead, use strcpy() for that purpose.