So I have some code which reads from a file and separates by the commas in the file. However some things in the file often have spaces after or before the commas so it's causing a bit of a problem when executing the code.
This is the code that I which reads in the data from the file. Using the same kind of format I was wondering if there was a way to prepare for this spaces
while(getline(inFile, line)){
        stringstream linestream(line);
        // each field of the inventory file 
        string type;
        string code;
        string countRaw;
        int count;
        string priceRaw;
        int price;
        string other;
        // 
        if(getline(linestream,type,',') && getline(linestream,code,',')
        && getline(linestream,countRaw,',')&& getline(linestream,priceRaw,',')){
            // optional other
            getline(linestream,other,',');
            count = atoi(countRaw.c_str());
            price = atoi(priceRaw.c_str());
            StockItem *t = factoryFunction(code, count, price, other, type);
            list.tailAppend(t);
       }
    }
 
    