| strings/knold-tot-c-like-2.cc - The Knold & Tot example with char[]. | Lecture 2 - slide 18 : 28 Program 3 |
// Illustrates that C-like strings cannot be assigned.
// The similar assignment is possible on C++ strings.
#include <iostream>
void g(){
char s1[6] = "Knold",
s2[6] = "Tot ";
s1 = s2; // Compiler error: Invalid array assignment
s2[1] = 'u'; // OK.
std::cout << s1 << " og " << s2 << std::endl;
}
int main(){
g();
}