#How to use getline to get csv and store values into a struct
41 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
std::string line;
while(std::getline(stream, line)) {
auto str = std::stringstream{std::move(line)};
std::string word;
while (std::getline(str, word, ',')) {
// do stuff with each word
}
}
Im doing it in a function like this:
void gatherData(Data * p, numLines){
for (int i = 0; i < numLines; i++){
getLine(input, 80, ',')
}
}```
where does the getLine store what it gets?
That won't even compile.
yeah I took it out of the function this is what I have but Im getting an error
i dont know what im doing wrong
Ok so fix the error. 
please help me
You do realize I can't do anything without the error?
That's a lot of spaghetti.
Don't use new in modern C++.
Just use a damn vector.
It's telling you it's not a pointer.
new is all i know as of now
Use . not ->
So learn... Using new/delete has been obsolete since 2011.
And using a new array has been obsolete since 1998.
You can't call getline on a char array, use std::string.
Its a struct though
So?
#include <string>
how do I make my char into a string
A single char?
cstring