char array through function

I have been busy in trying to pass 2d array through function but no break through can any one point out the issue as i am in dire need of help
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
int main()
{
const int num=11;
const int length =100;
char directory[num][length] = 
{   "Becky Warren, 555-1223",
    "JoeLooney, 555-0097",
    "Geri Palmer, 555-8787",
    "Lynn Presnell, 555-1212",
    "Holly Gaddis, 555-8878",
    "Sam Wiggins, 555-0998",
    "Bob Kain, 555-8712",
    "Tim Haynes, 555-7676",
    "Warren Gaddis, 555-9037",
    "Jean James, 555-4949",
    "Ron Palmer, 555-2783"};

searchDirectory( directory);

}

void searchDirectory(char **& directory)
{
cout<<"The Array is passed \n";
}
Last edited on
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
#include <iostream>
using namespace std;

const int length =100;

void searchDirectory(char directory[][length]);

int main()
{
   const int num=11;
   char directory[num][length] = 
      {   "Becky Warren, 555-1223",
          "JoeLooney, 555-0097",
          "Geri Palmer, 555-8787",
          "Lynn Presnell, 555-1212",
          "Holly Gaddis, 555-8878",
          "Sam Wiggins, 555-0998",
          "Bob Kain, 555-8712",
          "Tim Haynes, 555-7676",
          "Warren Gaddis, 555-9037",
          "Jean James, 555-4949",
          "Ron Palmer, 555-2783"};

   searchDirectory( directory);

}

void searchDirectory(char directory[][length])
{
   cout<<"The Array is passed \n";
}


I think you would find it easier with vector<string> though.
Last edited on
Topic archived. No new replies allowed.