header.h
#include <iostream>
#include <vector>
class CombatLine{
std::stringstream Line;
std::vector<std::string> TokenLine;
void SetLine(std::string s){
Line<<s;
}
public:
void SetTokenLine(){
int i=0;
while(i<5){
Line>>TokenLine[i];
i++;}
TokenLine.resize(i);
for(int j=0;j<5;j++)
cout<<TokenLine[j];}
main.cpp
#include "Header.h"
using namespace std;
int main () {
CombatLine Line1;
Line1.SetLine("[Combat] A bird attacks -Anthrax- and misses (dodge).");
Line1.SetTokenLine();
}
This builds but I get this runtime error, /cygdrive/C/Program Files/NetBeans 6.9.1/ide/bin/nativeexecution/dorun.sh: line 33: 4500 Segmentation fault <core dumped> sh "$<SHFILE>"
I know it has to do with how I am manipulating strings & streams in the SetTokenFile, but I can't seem to pinpoint what.
This is a small piece to a larger project. Overall I am going to parse a dynamic text file, and later do comparisons on the entire file's contents.
<in your code block get removed (not to mention invalid HTML is generated). (Also, using namespace std; needs to die a horrendous death)