I'm very new to C++ and im trying to create a program that takes in request from user like this:
i7: 43 2 21 A
basically the format it has to follow is after i there should be a number without any space followed directly by : and then spaces between the numbers and finally the last character should be A.. User can choose to input as many numbers as they want in between : and A. and if the input is any different from this format, user gets an error.
I somehow managed to get some part done (although still need to figure out what to do about the whole spacing thing) but i am not able to store that last character A idk why... Here is what I have done so far.
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int size;
    vector<long double> nums;
    long double numbers;
    char c1, c2, c3;
    if (cin >> c1)
    {
        if (cin >> size >> c2 && c1 == '<' && c2 == ':')
        {
            while (cin >> numbers)
                nums.push_back(numbers);
            cin>>c3;  //this doesn't work or even get called
            cout<<c3<<endl;
            for(int i=0;i<nums.size();i++)
            {
               cout<<nums[i]<<endl;
            }
        }
        else{
            cout<<"error"<<endl;
        }
    }
    return 0;
}
 
    