Ralf Ralf - 1 year ago 72
C++ Question

function prototype for a two dimensional array

Im writing the function prototype for function that contains two arrays

void fillAndDisplay(int data[50][8], string names[50]) //prototype

fillAndDisplay(data, names); // call

void fillAndDisplay(int data[50][8], string names[50]){ // definition


The compiler doesn't like this. What am I doing wrong?

[Example of a call attempt]

int main()

fillAndDisplay(data, names);

return 0;


It underlines data and names and says "no instance of overload function matches the required data type.

Answer Source

This compiles just fine:

#include <string>

void fillAndDisplay(int data[50][8], std::string names[50]); //prototype

int main() {
  int data[50][8];
  std::string names[50];
  fillAndDisplay(data, names); // call

  return 0;

void fillAndDisplay(int data[50][8], std::string names[50]){ // definition

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download