C++ Problem

I don't know what I am doing wrong. I keep getting a bunch of errors and do not know what they mean. Please help!

1. Your program asks the user for six integers and stores them in an array. Then, it asks
for six characters and stores them in a second array.
2. The program then prints a bar chart made of the characters provided (with the heights
corresponding to the integers.
3. Lastly, a sorted bar chart (lowest to highest) should be printed.
Use arrays and functions. Recursion is not necessary

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
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;

void printChart (int h[], char c[], int cap, int max){
        for (int r=max; r>=1; r--) {
                for (int col=0; col<cap; col++){
                        if(h[col]>=r) cout << " " << c[col];
                        else cout << " ";
                }
        cout << endl;
        }
}

void swap (int h[], char c[], int i , int i){
        int th=h[i];
        char tc=c[i];
        h[i]=h[j];
        c[i]=c[j];
        h[j]=th;
        c[j]=tc;
}

void sort (int h[], char c[], int cap){
        for(int i=0;i<cap-1;i++) {
                int index=minIndex(h,i,cap-1);
                swap(h,c,i,index);
        }
}

int minIndex (int h[], int low, int high){
        int min=low;
        for(int i=low; i<=high; i++)
        if (h[i]<h[min]) min=i;
        return min;
}

int getMax (int h[], int cap){
        int maxVal=h[0];
        for (int i=1; i<cap; i++)
        if(h[i]>maxVal) maxVal=h[i];
        return maxVal;
}

int main() {
        int height[6]={0};
        string char[6];
        cout << "Enter six non-negative integers." << endl;
        for (int i=0; i<6; i++) {
                cout << "Integer" << i << ": ";
                cin >>  height[i];
                while (height[i]<0) {
                        cout << "Please enter a positive number: ";
                        cin >> height[i];
                }
        }
        cout << "Enter six characters." << endl;
        for (int i=0; i<6; i++) {
                cout << "Character: ";
                cin >> char[i];
        }

int maxHeight=getMax(height, 6);

cout << "Unsorted Bar Chart" << endl;
printChart(height, char, 6, maxHeight);
sort(height, char, 6);
cout << endl;
cout << "Sorted Bar  Chart" << endl;
printChart(height, char, 6, maxHeight);

return 0;
}
What kind of error? You need to provide more information. Not many people are going to voluntarily compile and debug the program for you, and then guess as to what the error is that you are asking about.
I have no experience with c++, I am only taking this class as a requirement. We have never went over errors in the class so I have no idea what they mean.

hw10.cpp: In function âvoid sort(int*, char*, int)â:
hw10.cpp:30:31: error: âminIndexâ was not declared in this scope
int index=minIndex(h,i,cap-1);
^
hw10.cpp: In function âint main()â:
hw10.cpp:52:13: error: expected unqualified-id before â[â token
string char[6];
^
hw10.cpp:65:10: error: expected primary-expression before âcharâ
cin >> char[i];
^
hw10.cpp:65:10: error: expected â;â before âcharâ
hw10.cpp:71:20: error: expected primary-expression before âcharâ
printChart(height, char, 6, maxHeight);
^
hw10.cpp:72:14: error: expected primary-expression before âcharâ
sort(height, char, 6);
^
hw10.cpp:75:20: error: expected primary-expression before âcharâ
printChart(height, char, 6, maxHeight);
I tried going through some of the errors and was able to clear it up a bit, I am still having these two errors and am not sure what to do.

hw10.cpp: In function âvoid sort(int*, char*, int)â:
hw10.cpp:30:31: error: âminIndexâ was not declared in this scope
int index=minIndex(h,i,cap-1);
Topic archived. No new replies allowed.