Cannot Interpret Compiler Error

Hello. I am creating a program to read the data from a file, remove the quotations from the words and store the words without quotations in a vector. However, I am getting this compiling error that I cannot interpret. The code and compiler error are below, and here is a link to the text file:
http://projecteuler.net/project/words.txt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <vector>
#include <cmath>
#include <fstream>
using namespace std;
int main() {
  //read from "words.txt" into data
  ifstream infile;
  infile.open("words.txt");
  string data;
  infile >> data;
  infile.close();
  
  //breaks the words apart and stores them in vector
  vector<string> words;
  vector<string> tempWords = ""; //"buffer" for words
  long ch = 1;
  while(ch < tempWords.size()) {
      while(data[ch] != '\"') {
	tempWords = tempWords + data[ch];
	++ch;
      }
      words.push_back(tempWords);
      ch+=3;
  } 

  cout << words[0] << words[1] << words[3];
  return 0;
}

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/vector:550:5: note: 
      candidate constructor not viable: no known conversion from
      'const char [1]' to 'const std::__1::vector<std::__1::basic_string<char>,
      std::__1::allocator<std::__1::basic_string<char> > > &' for 1st argument
    vector(const vector& __x);


Thanks!
You declared `tempWords' as a vector, ¿is that what you want?
it seems that you are using it as a `string'
Ha, thanks. I tend to mix up my variables sometimes.

edit: wish it would just say that instead of saying "inviable candidate constructor" haha
Last edited on
Topic archived. No new replies allowed.