I want this program to go through a character array and display each element until the null character is reached. This is basically the code from my textbook, but when I try it, the loop never stops. What am I doing wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13
int main() {
constint LENGTH = 80;
char line[LENGTH];
cout << "Enter a sentence: ";
cin.getline(line, LENGTH);
for (int index = 0; line[index] != '/0'; index++) {
cout << line[index];
}
return 0;
}