Being new to C++ I have tried to created a simple void function within one of my programs in order to display an array. There is however an error as seen in the title. I believe it is a problem in the fact I am trying to call it with an array in a different form than the functions parameters. I am unsure how to amend that.
#include <iostream>
#include <vector>
using namespace std;
void display_array(string arr[]){
int i;
for (i = 0; i < sizeof(arr); i++);
cout<<arr[i];
}
int main()
{
string current;
std::vector<string> paths;
cout<<"Input paths in the form 'AB'(0 to exit)";
cin>>current;
while (current != "0"){
paths.push_back(current);
cin>>current;
}
display_array(paths);
}
Any help is appreciated.
display_arrayshould print anstd::vector<std::string>, make the argumentconst std::vector<std::string>>&.forloop has a semicolon on the end which means that the loop will do nothing but incrementiand the next line will be executed once.