Assigning C-strings

Assigning C-strings

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."

You cannot assign a C-string using operator =. Instead, use strcpy() for that purpose.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular