How to use a delimeter on getline
<p>I have a file which I am supposed to read each line and store it in struct of arrays, I am reading the file fine but the results are kind mixed because the data is separated by comma, how do I make it read the line separated by commas?</p>

<pre><code>struct Data{
    std::string a;
    std::string b;
    std::string c;
}

int main(){
Data cd[100];

std::ifstream inFile;  
std::string data;
inFile.open("data.txt");                 
if(inFile.good()){                       
    while(getline(inFile, data)){ //when I add, ',' right after data nothing shows up 
        std::stringstream ss(data);     
        ss &gt;&gt;cd[0].a &gt;&gt; cd[0].b &gt;&gt; cd[0].c;
        std::cout &lt;&lt;cd[0].a&lt;&lt;std::endl;
    }
}
else{
std::cout &lt;&lt; "can't open" &lt;&lt; std::endl;
}

inFile.close();    
//close the file
return 0;
}
</code></pre>