-2

I have a template function makeMatrix(), code is:

template<size_t N>
void makeMatrix(string dataFilePath, int adjcMatrix[N][N])
{
  fstreamExtension fe("adj.txt", ios::in|ios::binary);
  string s;
  vector<int> temp;
  int i = 0;

  while(!fe.eof())
  {
      getline(fe, s);
      temp = tokenizeToInt(s, ",\n")); //error: expected ';' before ')' token|

      for(int j = 0; j < N; j++)
          adjcMatrix[i][j] = temp[j];

      i += 1;
  }
}

fstreamExtension is a class I created and is included in program through header #include "fstreamExtension.h", other included headers are iostream string and boost/tokenizer.hpp.

code for tokenizeToInt():

vector<int> tokenizeToInt(string& intString, const char* seperators)
{
   vector<int> intValues;

   boost::char_separator<char> delims(seperators);
   boost::tokenizer<boost::char_separator<char>> tokens(intString, delims);

   for (const auto& t : tokens) {
       intValues.push_back(atoi(t.c_str()));
   }

   return intValues;

}

Why it is causing a compilation error in the makeMatrix(), the syntax seems correct, I didn't called it in main(), was compiling some other code then this error popped up when I started a build.

IDE : codeblocks 16.01, gcc.

Some programmer dude
  • 363,249
  • 31
  • 351
  • 550
Code Devil
  • 17
  • 7

1 Answers1

1

You should listen to what the compiler tells you. Often the error is simpler than you think:

temp = tokenizeToInt(s, ",\n")); //error: expected ';' before ')' token|

An extra right-parenthesis. The compiler error means "I thought you were done with this command, why are you trying to close another parenthesis-pair?"

einpoklum
  • 86,754
  • 39
  • 223
  • 453