How to use numerical representation of a character to insert in a string???

Consider I want to check in a string for many values. Let's say I have the value char letter = 'a', and I want to insert it in every position of a string, let's say "home". Then I want to check for letter = 'b' in the same string "home", and just like that I want to check for every letter in the alphabet nad insert it in the string "home"
Is there a way to use the numerical representation of a char 'a' to insert in a string, and then increase a count so that the next value of char is 'b', and so on until we reach 'z'???
Thanks.
gjgomezAsked:
Who is Participating?
 
beryl666Connect With a Mentor Commented:
if you want to add 'a' until 'z' after the string "home", you can do this.

#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
    char letter = 'a';
    string s="home";
    for(int i=0;i<26;i++)
    s=s+char(letter+i);
 cout<<s;
 getch();
 return 0;  
}
0
 
beryl666Commented:
don't understand your question. explain more please.
0
 
beryl666Commented:
ok let me do this:

you want to change the char letter='a'; and make it increase in numeric until z
#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
    char letter = 'a';
   
    for(int i=0;i<26;i++)
    cout<<char(letter+i);
 
 getch();
 return 0;  
}
0
All Courses

From novice to tech pro — start learning today.