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: 
Your definition is a bit small:

```
"hello" = "85121215
h = 8
e = 5
l = 12
o = 15

```

I assume you mean that

```
a = 1
b = 2
...
z = 26

```

in which case it is not that hard:

```
std::string meh_conv(char c) {
    switch(c) { // (or `switch(tolower(c))` and save some typing)
    case 'a': case 'A': return "1";
    case 'b': case 'B': return "2";
    ....
    case 'z': case 'Z': return "26";
    ....
    // insert other special characters here
    }
    throw std::range_error("meh");
}

std::string meh_conv(std::string const &src) {
    std::string dest;
    for (const auto c : s)
       dest += meh_conv(c);
    return dest;
}

```

or use `std::transform()`:

```
#include <algorithm>

std::string dest;
std::transform (src.begin(), src.end(), back_inserter(dest),
                meh_conv)

```

(doesn't work for different incoming and outgoing types, at least not as is)

---

Addendum.

You possibly want to parametrize the replacement map:

```
std::map<char, std::string> repl;
repl['a'] = repl['A'] = "0";
repl[' '] = " ";

std::string src = "hello";
std::string dest;
for (const auto c : src) dest += repl[c];

```
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;

}

```