I have been having difficulty using stringstream in a loop. Upon investigation, I have found that stringstream is apparently not intended to be used in loops, so I tried to get around it by writing a function and then having my other function call that function. Unfortunately, I receive a compile error when I try to do this - I've been trying to search for how to call functions in other functions but I mainly see information about this in the body as opposed to "custom" functions like I'm trying to write.
Basically, I am trying to take a vector with numeric string values and transform it into a vector with long values. (The test case I use is small, the actual values I will be using are much larger and the vectors will also have more elements. I just wanted to make sure that the logic structure worked before I used it with the full set of values.)
Thank you for the response! I was able to use the second cope snippet you provided :)
Another issue I had, aside from stringstream, is that if I called StringToInt inside transformVector then I would receive an error that StringToInt wasn't defined in that scope. Just for further clarification to me: can I call one "custom" function into another (e.g. StringToInt inside transformVector)? (I feel like it would make sense that this should be doable somehow?) If so, how do I use one function inside another?
Another issue I had, aside from stringstream, is that if I called StringToInt inside transformVector then I would receive an error that StringToInt wasn't defined in that scope.
Did you notice line 3 in the first snippet provided by JLBorges?
StringToInt wasn't visible in transformVector. Adding a declaration of StringToInt before the definition of transformVector makes it visible.
Oh! I didn't realize JLBorges was declaring StringToInt first for that reason - I thought s/he was just correcting the way I was storing the information to the new (long) vector. Thank you!