Ok, so I've done this before but I can't remember how. Ignore all the extraneous code, it will be used later, but I wanted to show everything. I need to pass 3 string arrays to a print function (and it must be done in another function for later use) but you can only return ints out of main so how do I get around that?
Here is my code:
#include<iomanip>
#include<fstream>
#include<iostream>
using namespace std;
#define SIZE 100
string output_function(string, string, string, int i);
class fl_friends{
public:
string first;
string last;
string current;
};
int main(int argc, char**argv)
{
int i; //index variable//
string a_name[SIZE];
string a_var1[SIZE];
string a_var2[SIZE];
/***********************************************************************
Function
*********************************************************************/
string output_function(string name[SIZE], string var1[SIZE], string var2[SIZE], int i)
{
while(i >= 0)
{
cout << setw(15) << left << name[i]
<< setw(3) << left << var1[i]
<< setw(3) << left << var2[i]
<< endl;
i--;
}
exit(1);
}
The error message is: error: conversion from 'std::string*' to non-scalar type 'std::string' requested
Your function declaration: string output_function(string, string, string);
doesn't match your function definition: string output_function(string name[SIZE], string var1[SIZE], string var2[SIZE])