Link to home
Start Free TrialLog in
Avatar of TechMonster
TechMonster

asked on

c++ get first letter in variable

how do you get the first letter of a stored variable.  
ASKER CERTIFIED SOLUTION
Avatar of josgood
josgood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TechMonster
TechMonster

ASKER

string FullName, FirstName, LastName;
char FN_initial;
char LN_initial;
do you have to have an array
A character string is an array of characters, so yes.

Are you trying to do something else?
Avatar of Infinity08
>> do you have to have an array

No. It would also work with a C++ string :

        string FirstName = "John";
        string LastName = "Doe";
        char FN_initial = FirstName[0];
        char LN_initial = LastName[0];