Help understanding Arrays

Hello to the community and thank you in advance. I'm having a little bit of trouble with this code. I need to "merge" all of similar number inputs and display the total of times it was typed in. I can see a list of them, but not the combined total. Thank you. Using Dev-C++

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  #include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
using namespace std;

//Global Constant
const int MAXSIZE = 50;

//Function Declarations
void fillArray(int a[], int size, int& numberUsed);
/*fillArray will take the contents of an external file or
the input from the keyboard to fill the array*/
void findDuplicates(int a[], int b[], int size, int& numberUsed);
/*findDuplicates will create another array in which to keep
track of values that repeat in the original array*/
void showArray(int a[], int b[], int size, int& numberUsed);
/*showArray will display the contents of the arrays*/

int main()
{
	int numberUsed, list[MAXSIZE], repeats[MAXSIZE];
	
	fillArray(list, MAXSIZE, numberUsed);
	findDuplicates(list, repeats, MAXSIZE, numberUsed);
	showArray(list, repeats, MAXSIZE, numberUsed);
	return 0;
}

//Function Definitions
void fillArray(int a[], int size, int& numberUsed)
{
	char source, fileName[15];
	ifstream read;
	int i, next;
	
	cout << "Would you like to use an external file to fill the array.\n"
		 << "Type Y or N and press enter: ";
	cin >> source;
	
	if(source == 'y' && source == 'Y')
	{		
		cout << endl 
			 << "Please enter the name of the file, up to 15 characters long.\n"
			 << "include the file's extension (file.txt): ";
		cin >> fileName;
		read.open("fileName");
		if(read.fail())
		{
			cout << endl
				 << "Could not open file";
			exit(1);
		}
		for(i=0; i<numberUsed; i++)
		{
			while(read >> next);
			{
				a[i] = next;
			}
		}
	}
	else
	{
		cout << endl
			 << "Please enter a list of numbers separated by a space.\n"
			 << "You can add up to 50 numbers. Type -1000 to finish input: ";
		cin >> next;
		while( (next != -1000) && (i < size) )
		{
			a[i] = next;
			i++;
			cin >> next;
		}
		numberUsed = i;
	}
}

void findDuplicates(int a[], int b[], int size, int& numberUsed)
{	
	int repeats;
	
	cout << endl << "N\tCount" << endl;
	for(int i=0; i<numberUsed; i++)
	{
		if(a[i] == a[i])
		{
			b[i] = repeats;
			b[i]++;
		}
	}
}
void showArray(int a[], int b[], int size, int& numberUsed)
{
	for(int i=0; i<numberUsed; i++)
	{
		cout << endl << a[i] << "\t" << b[i];	
	}
}
Posting a wall of code and giving a vague description of the problem is not going to get you many answers. What specifically is wrong? Is it a compiler error? Is it not doing what you think it should? What is it doing/supposed to do?
Sorry about that, I thought that if I shared my code it might be easier to understand. Basically it's not working like it should. if I type for input:

1 1 1 2 3 5 5

it should show

1 3
2 1
3 1
5 2

I get

1 1
1 2
1 3
2 4
3 5
5 6
5 7
Topic archived. No new replies allowed.