Hi, im trying to make a C++ project for my class which reads the input from a text file and outputs the mean, median, and mode. but im running into an error i get when i run it. i get this error when i try to build it

error C2040: 'name' : 'std::string' differs in levels of indirection from 'char [16]'
error C2088: '>>' : illegal for class

here is my current code. its too long to post here so i had to put it on pastebin

    #include <iostream>
    #include <fstream>
    #include <iomanip>
    #include <string>
    using namespace std;
    const int MAX_SIZE = 100;
    void Fill_Array(int Size[], int& count, int& numbers_used);
    void Print_Array(int Size[], int count);
    double Calc_Average(int Size[], double average);
    void Sort(int Size[], int numbers_used);
    void Swap(int& v1, int& v2);
    int index_of_smallest(const int Size[], int start_index, int number_used);
    int Calc_Median(int median, int Size[]);
    void Print_Array_and_Calculations(int median, double average);
    int main()
    {
            ifstream in_size;
            int count;
            int Size [MAX_SIZE],
                    numbers_used = 0,
                    median = 0;
            double average = 0.0;
            Fill_Array(Size, count, numbers_used);
            Print_Array(Size, count);
            average = Calc_Average(Size, average);
            Sort(Size, numbers_used);
            Calc_Median(median, Size);
            Print_Array_and_Calculations(median, average);
            in_size.close();
            return 0;
    }
    void Fill_Array(int Size[], int& count, int& numbers_used)
    {
            int size;
            char name[16];
            ifstream in_size;
            string name;
            in_size.open (name);
            cout << "Enter the file to read in: ";
            cin >> name;
            cout << endl << "The numbers in the array are:" << endl << endl;
            if(in_size.fail())
            {
                    cerr << "Error opening file" << endl;
                    exit(1);
            }
            count = 0;
            in_size >> size;
            while((!in_size.eof()) && (count <= MAX_SIZE))
            {
                    Size[count] = size;
                    count++;
                    in_size >> size;
            }
            in_size.close();
    }
    void Print_Array(int Size[], int count)
    {
            int number_used = 0;
            for(int index = 0; index < number_used; index++)
                    cout << Size[index] << " ";
    }
    double Calc_Average(int Size[], double average)
    {
            int total = 0;
            for (int i = 0; i < MAX_SIZE; i++)
            {
                    total = total + Size[i];
            }
            average = double(total) / MAX_SIZE;
            return average;
    }
    void Sort(int Size[], int number_used)
    {
            int index_of_next_smallest;
            for (int index = 0; index < number_used - 1; index++)
            {
                    index_of_next_smallest = index_of_smallest(Size, index, number_used);
                    Swap(Size[index], Size[index_of_next_smallest]);
            }
    }
    void Swap(int& v1, int& v2)
    {
            int temp;
            temp = v1;
            v1 = v2;
            v2 = temp;
    }
    int index_of_smallest(const int Size[], int start_index, int number_used)
    {
            int min = Size[start_index],
                    index_of_min = start_index;
            for (int index = start_index + 1; index < number_used; index++)
                    if(Size[index] < min)
                    {
                            min = Size[index];
                            index_of_min = index;
                    }
                    return index_of_min;
    }
    int Calc_Median(int median, int Size[])
    {
            median = Size [ MAX_SIZE / 2 ];
            return median;
    }
    void Print_Array_and_Calculations(int median, double average)
    {
            cout << endl << "The average of the numbers is " << average;
            cout << endl << "The median of the numbers is " << median;
            cout << endl << endl;
    }

Line 35:

            char name[16];

Line 37:

            string name;

You can't have two declaration of variables with the same name. This can be don when declaring functions, but with different arrities, but here, you either put char name[16] and string name1, or leave just 1 variable (I would suggest to leave the string name; one).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.