0

Hello:
I'm almost killing myself to figure out the problem with the attached code. It seems that passing a text array to a function is impossible. Anyone is so kind to help me, please.

Attachments
#include <fstream> 
using std::ifstream; 
using std::ofstream;
#include <string>
using std::string;

#include <cstring>
#include <cctype>
#include <iostream>
using std::cerr;
using std::cout;
using std::endl;
using std::ios;

#include <iomanip>
#include <cmath>
using namespace std;


void printTxtArray(char *[4]);



int main()
{
const char *outputLegend[4]={"efficiency","PressLossCoeff","swirlVelocity1","swirlVelocity2"};
printTxtArray(outputLegend);
}

void printTxtArray(char *B[])
{
int i;
for (i=0;i<4;i++)
cout << B[i] <<endl;
}
2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Ancient Dragon
0

you declared outputLegend as const array but trying to pass it to a function that expects non-const. Change the function to require const

void printTxtArray(const char *B[]);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.