This program is suppose to grab the first letter of each name and then output the initials.

#include <iostream>
using namespace std;
const char blank= ' ';
const char newline= '\n';

void main()
{
    //Declare character variables
    char firstInitial, middleInitial, lastInitial;

cout<<" Please enter first, middle, and last name separated by spaces "<< newline;

cin.get(firstInitial); 
cin.ignore(100,blank);

cin.get(middleInitial) ;
cin.ignore(100,blank);

cin.get(lastInitial); 
cin.ignore(100,blank);

cout << "The initials are: "<< firstInitial, middleInitial, lastInitial;

system("pause");

}

thats a great story, but you are more likely to get help if you say what is doing aswell as what it is supposed to do.

In my opinion, it would be much easier to think of the each name as separate character arrays. Take each name in separately and print the 0th element of each.

#include <iostream>
#define MAX 20
using namespace std;

int main()
{
    char first[MAX];
    char last[MAX];
    char mid[MAX];
    
    cout<<"enter first name"<<endl;
    cin>>first;
    cout<<first[0];

     return 0;
}

That should be able to get you on the right track.

EDIT: If you need to use the get and ignore functions, sorry to have wasted both of our time.

Thank you all for the help.

#include <iostream>
#include <string>
using namespace std;


void main()
{
    char blank = ' ', newline = '\n', firstInitial, middleInitial, lastInitial;
    string first, middle, last;

    cout << "PLease enter first, middle, and last" << endl;

    cin.get(firstInitial);
    cin.putback(firstInitial);
    cin>>first;  
    cin.ignore(100,blank);  

    cin.get(middleInitial);
    cin.putback(middleInitial);
    cin>>middle;
    cin.ignore(100,blank);

    cin.get(lastInitial);
    cin.putback(lastInitial);
    cin>>last;
    cout<<"your name is :"<< first << middle<< last<<endl;
    cout << "Your Initials are " << firstInitial << middleInitial << lastInitial << endl;

    system("pause");

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.