?
Solved

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

Posted on 2005-03-27
3
Medium Priority
?
209 Views
Last Modified: 2010-04-24
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.
0
Comment
Question by:gjgomez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 5

Expert Comment

by:beryl666
ID: 13641355
don't understand your question. explain more please.
0
 
LVL 5

Expert Comment

by:beryl666
ID: 13641371
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
 
LVL 5

Accepted Solution

by:
beryl666 earned 2000 total points
ID: 13641376
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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question