• Register
100 points
7 2
Welcome to Kodlogs, programming questions and answer website.

The above error means that the programmer tried to index into a string using an index that is not valid. An index means an array of related data stored under a single variable or variables of the same type stored in one file type. 


When the loop is testing the conditions that have been set and find that the index is not a group type of array of others in the system, the index will be out of range.

 See below;
y equals source.size()                     assume y is not a valid index, 

so temp.at(y) throws std::out_of_range
Based on the above example, if the string length is “n” the valid indices will be 0 through n-1. Thus, string ‘n’ will be out of range when used and the above error will occur. 


The possible way to solve the error will be to ensure that the indices declared are within the range of the index array. 
Another way to navigate through is to use size_t instead of unassigned long when dealing with sizes so that the long integers can be truncated to allow the index fit in the arrays defined in the system. 



#include <iostream>
#include <string>
using namespace std;
int main() {
   string s;
    int i;
    char c;
        if((s.at(i)>='a'&&s.at(i)<='z')||(s.at(i)>='A'&&s.at(i)    <='Z')){
    return 0;

The above program also has few other errors like sizeof(s) instead of s.length() and the starting index value is 1 not 0. But after understanding this program you will get to know the concept of “Terminating With Uncaught Exception of Type Std”

Hope this helps.


100 points
7 2