Question: I have a string and the first element is for example 'a'. I already declared a variable called a ( so int a=1 for example). My question now is, how can I convert the whole string to numbers (a=1,b=2,c=3,...z=26)? Example:

`string str="hello";` this has to be changed to `"85121215"` and then changed to 85121215.

Answer: 
```
// transformation itself doesn't care what encoding we use
std::string transform_string(std::string const &in, std::function<int(char)> op)
{
    std::ostringstream out;
    std::transform(in.begin(), in.end(),
                   std::ostream_iterator<int>(out),
                   op);
    return out.str();
}

// the per-character mapping is easy to isolate
int ascii_az_map(char ch)
{
    if (ch < 'a' || ch > 'z') {
        std::ostringstream error;
        error << "character '" << ch << "'=" << (int)ch
              << " not in range a-z";
        throw std::out_of_range(error.str());
    }
    return 1 + ch - 'a';
}

// so we can support other encodings if necessary
// NB. ebdic_to_ascii isn't actually implemented here
int ebcdic_az_map(char ch)
{
    return ascii_az_map(ebcdic_to_ascii(ch));
}

// and even detect the platform encoding automatically (w/ thanks to Phresnel)
// (you can still explicitly select a non-native encoding if you want)
int default_az_map(char ch)
{
    #if ('b'-'a' == 1) && ('j' - 'i' == 1)
        return ascii_az_map(ch);
    #elif ('j'-'i' == 8)
        return ebcdic_az_map(ch);
    #else
        #error "unknown character encoding"
    #endif
}

// use as:
std::string str = "hello";
std::string trans = transform_string(str, ascii_az_map);
// OR ... transform_string(str, ebcdic_az_map);

```

---

Note that since the per-character mapping is completely isolated, it's really easy to change the mapping to a lookup table, support different encodings etc.
Easy Approach, 
you can find mod of char with 96 (ASCII value before a), as result it will always give you values in range 1-26.

```
int value;
string s;
cin>>s;
for(int i=0; i<s.size();i++){
    value = s[j]%96;
    cout<<value<<endl;

}

```