The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details. |
![]() |
Home ![]() ![]() |
||
![]() ![]() ![]() ![]() ![]() ![]() |
||
A Run-Time Error
So far, you probably haven't seen many run-time errors, because we haven't been doing many things that can cause one. Well, now we are. If you use the [] operator and you provide an index that is negative or greater than length-1, you will get a run-time error and a message something like this: index out of range: 6, string: bananaTry it in your development environment and see how it looks.
|
||
Home ![]() ![]() |