I have a array consisting of chars like [1,2,3,4,5,.,..] and I have a loop that looks like
for (size_t i = 0; i < size; ++i)
os << data[i]; // os is std::ostream&
This loop prints the array in the correct order without any errors. But when I use this loop to print it backwards
for (size_t i = (size - 1); i >= 0; --i)
os << data[i];
I get a segmentation fault error. Any reason why this can happen?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…