Previous Slide Changing/Comparing - Wrong Way Next Slide

The only way to change or compare the content of arrays is to deal with each element. In other words, we can't do the following:

ChangingComparing
char label[10] = "value";
char label2[] = "another";
char *labelPtr = label2;
label = "new val";  // No!
label = label2;     // Wrong!
label = labelPtr;   // Wrong!
char label1[] = "address";
char label2[] = "phone";

if (label1 == label2) // Not what you
                      // think it does!


BU CAS CS - Manipulating Strings - Lab
Copyright © 1993-2000 by Robert I. Pitts <rip at bu dot edu>. All Rights Reserved.