Compiler outputs this message making it look like I need to add more "*". What is wrong?

Here is my error message:

p2.cpp: In function `void outputResults(std::string&, int&, int&, std::string**)':
p2.cpp:91: error: expected primary-expression before ']' token

Notice it says "std::string**" with 2 "*"s, originally it said
p2.cpp: In function `void outputResults(std::string&, int&, int&, std::string**)':
p2.cpp:91: error: expected primary-expression before ']' token
with only 1 "*". So what else am I missing? Here is my updated function code.
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
30
31
32
33
34
35
36
37
#include<iostream>
#include<fstream>
#include<string>
using namespace std;

// Function Prototypes
void readFilename(ifstream&, string&);
void countCharsLines(ifstream&, int&, int&, char&);
void populateArray(ifstream&, string[]);
void outputResults(string&, int&, int&, string[]);

int main()
{
  // Variables
  ifstream inFile;
  string filename;
  int countLines;
  int countChars;
  char ch;
  string words[1000];

  // Function Calls
  readFilename(inFile, filename);
  countCharsLines(inFile, countLines, countChars, ch);
  populateArray(inFile, words);
  outputResults(filename, countLines, countChars, words);
  return 0;
}

// FUNCTION WITH ISSUES
void outputResults(std::string &filename, int &countLines, int &countChars, std::string* words[])
{
  cout << "Filename: " << filename << endl;
  cout << "Number of lines: " << countLines << endl;
  cout << "Number of characters: " << countChars << endl;
  cout << "Words: " << words[] << endl;
}
It shows two *s because passing arrays is pretty much passing a pointer, so it shows it as another *. Your error is coming from line 36, where you say words[], because that doesn't make any sense. You need some value in the brackets for it to work. I'm guessing you should use a loop to output everything in there.
Thank you! That was right all i had to do was remove the [] inside the function. Ugh! I'm so rusty at this stuff from summer vacation. Thank you!
Topic archived. No new replies allowed.