pointers array compile error

I have this program with multiple files. I am getting a compile error that says in intMain too few arguments to function showArray. I am at a loss as to how to fix it. I know I need a third argument in main to correspond to showArray. Here are my programs.

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
32
33
34
35
36
#include<iostream>
#include<fstream>
#include "arrBubbleSort.h"
#include "showArray.h"
#include "showArrPtr.h" 
         

using namespace std;

int main()
{
    ofstream outFile;
    outFile.open("outFile.txt");
    
    
    const int NUM_DONATIONS = 15;       //Number of Donations
    
    int donations [NUM_DONATIONS] = {5, 100, 5, 25, 10, 5, 25, 5, 5, 100, 10, 15, 10, 5, 10};
                                     
    int *arrPtr[NUM_DONATIONS];
    
    for (int count = 0; count < NUM_DONATIONS; count++)
        arrPtr[count] = &donations[count];
        
    arrBubbleSort(arrPtr, NUM_DONATIONS);
    
    outFile << "The donations, sorted in ascending order are:  \n";
    showArrPtr (arrPtr, NUM_DONATIONS, outFile);
    
    outFile << "The donations, in their original order are: \n";
    showArray (donations, NUM_DONATIONS);
    return 0;
    
}
    


1
2
3
4
5
#include <iostream>
#include <fstream>
using namespace std;

void showArray(int [], int, ofstream &outFile);


1
2
3
4
5
6
7
8
9
#include "showArray.h"

void showArray(int array[], int size, ofstream &outFile);
{
     for (int count = 0; count < size; count++)
         outFile <<array[count] << " ";
         outFile <<endl;
    
}


Thanks
Look at what the error says...?

You call showArray() like this:
showArray (donations, NUM_DONATIONS);

But define it as this:
void showArray(int array[], int size, ofstream &outFile)

Also, where you are defining the actually function (last piece of code), you don't want a ; after the function name.
I am no longer getting that error, but I am getting a linker error. Could someone tell me what I am doing wrong? Thanks
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
32
33
34
35
36
37
38
39
40
41
42
43
44
// CS 2308.0001 
// 23 September 2008
// prog3.cpp
// coded by Christy Sylvest
//This Program shows the donations made to 
//the United Cause by the employees of CK Graphics, Inc.
//It displays the donations in order from lowest
//to highest ans in the original order they were received.
#include<iostream>
#include<fstream>
#include "arrBubbleSort.h"
#include "showArray.h"
#include "showArrPtr.h" 
         

using namespace std;

int main()
{
    ofstream outFile;
    outFile.open("outFile.txt");
    
    
    const int NUM_DONATIONS = 15;       //Number of Donations
    
    int donations [NUM_DONATIONS] = {5, 100, 5, 25, 10, 5, 25, 5, 5, 100, 10, 15, 10, 5, 10};
                                     
    int *arrPtr[NUM_DONATIONS];
    
    for (int count = 0; count < NUM_DONATIONS; count++)
        arrPtr[count] = &donations[count];
        
    arrBubbleSort(arrPtr, NUM_DONATIONS);
    
    outFile << "The donations, sorted in ascending order are:  \n";
    showArrPtr (arrPtr, NUM_DONATIONS, outFile);
    
    outFile << "The donations, in their original order are: \n";
    showArray (donations, NUM_DONATIONS, outFile);
    return 0;
    
}
    

1
2
3
4
5
#include <iostream>
#include <fstream>
using namespace std;

void showArray(int [], int, ofstream &outFile);

1
2
3
4
5
#include <iostream>
#include <fstream>
using namespace std;

void showArrPtr (int *[], int, ofstream &outFile);


1
2
3
4
5
6
7
8
9
#include "showArray.h"

void showArray(int array[], int size, ofstream & outFile)
{
     for (int count = 0; count < size; count++)
         outFile <<array[count] << "showarray";
         outFile <<endl;
    
}


1
2
3
4
5
6
7
8
9
10
11
#include "showArrPtr.h"


void showArrPtr (int *array[], int size, ofstream & outFile)
{
     
    
     for (int count = 0; count < size; count++)
         outFile << *(array[count]) << "showArrayPtr";
         outFile << endl;
}


1
2
3
4
5
#include <iostream>
#include <fstream>
using namespace std;

void arrBubbleSort (int *[], int);


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "arrBubbleSort.h"


void arrBubbleSort (int array[], int size)
{
     bool swap;
     int temp;
     
     do
     {
         swap = false;
         for (int count = 0; count < (size -1); count++)
         {
             if (array[count] > array[count +  1])
             {
                temp = array[count];
                array[count] = array[count + 1];
                array[count = 1] = temp;
                swap = true;
             }
         }
     } while (swap);
}    
Put header protection on your header files.

1
2
3
4
5
6
#ifndef FILENAME_H
#define FILENAME_H

//file

#endif 
Topic archived. No new replies allowed.