Using a bubble sort to alphabetize words.

Hello, I am currently working on a program that allows the user to insert a list of a words into an array that ends when the user enters a period. The program is to output the words in the original order they were entered, and then alphabetized by using a bubble sort. I cannot seem to get the bubble sort function to work.
When calling the Bubble sort function it says:
"Error: argument of type "char(*)[30]" is incompatible with parameter of type "char*"

Any help is greatly appreciated!

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
 #include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;



void outputwords (char strings [][30]);
void getnumbers (char strings[][30]);
void sortArray (char strings[],int size);


int main ()
{
	char strings[25][30];
	getnumbers(strings);
	outputwords(strings);
	sortArray (strings,25);
	
	system ("pause");
	return 0;
}

void getnumbers (char strings[][30])
{
		cout<<"Please enter a list of animal names, ending the list with a period."<<endl;

	for (int i = 0;i < 25; i++)
	{
		cin >> strings[i];
		if (strcmp(strings[i],".")==0)
		{
			break;
		}
	}
}

void outputwords (char strings [][30])
{
		
	for (int i = 0; i < 25;i++)
	{
		cout<< strings[i]<<" ";

		if (strcmp(strings[i],".")==0)
		{
			break;
		}
	}
}

void sortArray (char strings [], int size)
{
	bool swap;
	int temp;

	do
	{
		swap = false;
		for (int count = 0; count < (size-1); count++)
		{
			if (strings[count] > strings[count+1])
			{
				temp = strings[count];
				strings[count] = strings[count+1];
				strings[count+1] = temp;
				swap = true;
			}
		}
	} while (swap);
}
Last edited on
Topic archived. No new replies allowed.