I get this error in my c++ code Variable length array of non-POD element type string
(aka basic_string<char>
).
string words[numWords];
If I get rid of numWords and enter a number this works fine but if i put the same number in a variable it gives me the Variable length array of non-POD element type 'string' (aka 'basic_string<char>')
error, I have done it this way before and it worked in visual studio but I have now tried it in Xcode and it doesn't work. I have tried using vectors but I can't get them sot store any data and they just come back blank.
For those who asked this is my vector code should all be there
char ch;
ifstream repFile("//Users//bobthemac//Documents//c++asignment//c++asignment//test1.txt");
while(repFile.get(ch))
{
if(ch == ' ' || ch == '\n' || ch == '\t')
{
numWords++;
}
}
vector<string> words (numWords);
while(repFile >> x)
words.push_back(x);
repFile.close();