what is array of void and why am I getting it in the following program? I finally have the first part done where I can loop the input. However, I cannot figure out what this array of void is. I'm getting "declaration of 'lastname' as array of void" in lines 50-55 and 65-71. Also getting std::string Tom[4] previously declared here in line 60 and a redeclaration of std::string Tom[4] in line 63. Any thoughts?

#include <iostream>
#include <istream>
#include <iomanip>
#include <string>
using namespace std;

int namesort (void);

int main()
    int i = 0;
    string studentInfo[7][7];
    char inputDone = 'y';
    int stopLoop = 0;

        cout << "Please Input student's last name : ";
        cin >> studentInfo[i][0];

        cout << "Please Input student's first name : ";
        cin >> studentInfo[i][1];

        cout << "Please Input student's  ID Number : ";
        cin >> studentInfo[i][2];

        cout << "Please Input student's Test 1 Grade : ";
        cin >> studentInfo[i][3];

        cout << "Please Input student's Test 2 Grade : ";
        cin >> studentInfo[i][4];

        cout << "Please Input student's Test 3 Grade : ";
        cin >> studentInfo[i][5];

        cout << "Are there anymore student grades to enter? (y/n)";
        cin >> inputDone;
} while (inputDone = 'y');

        //Last Name string arrays
        string Ant [4];
        string Doe [4];
        string Mix [4];
        string Nerd [5];
        string Sunday [7];
        string Thumb [6];

        void (*ptr) [] = { Ant, Doe, Mix, Nerd, Sunday, Thumb };        
        void lastname [0] = Ant;
        void lastname [1] = Doe;
        void lastname [2] = Mix;
        void lastname [3] = Nerd;
        void lastname [4] = Sunday;
        void lastname [5] = Thumb;
        //First name strings        
        string Adam [5];
        string Jane [5];
        string Tom [4];
        string Bobby [6];
        string Billy [6];
        string Tom [4];
        void firstname [] = { Adam, Jane, Tom, Bobby, Billy, Tom };
        void firstname [0] = Adam;
        void firstname [1] = Jane;
        void firstname [2] = Tom;
        void firstname [3] = Bobby;
        void firstname [4] = Billy;
        void firstname [5] = Tom;

        system ("pause"); 
        return 0;


Also trying to get this to bubble sort alphabetically by last name, but haven't quite made it that far as I really don't know what needs to be done to do a string bubble sort. Third problem: what is a parallel array? I have to put letters and numbers into a table and I'm really lost on what to do there too.

7 Years
Discussion Span
Last Post by ArkM

Consider that you have declared them as type 'void'...perhaps you want them to be 'string'?

But as above, that would just be scratching the surface. That code is.....?!


Look at the loop first, forget everything after that.

You have a counter (i), initialized to 0.
You have a 2D array of strings (students), presumably 7 students with 7 attributes each.
You have an 'inputDone' char.

Firstly you never increment the counter, at the end of the loop you should increment the counter otherwise you just keep over-writing the first element in the array.
Secondly the condition for exiting the loop while (inputDone = 'y'); = is an assignment, == is a comparison. Additionally if you enter more than 7 students you will go over the bounds of your array so your exit condition should be that inputDone is equal to (comparison) 'y' or (or operator ||) i is greater than or equal to (>=) 7. Remembering that array indexes start at 0, so accessing 7 elements gives you valid indexes of 0-6 inclusive.

EDIT: with that block of code after the loop i honestly cannot even tell what you are trying to do, really it doesn't make any sense at all, you'll need to explain what it is you want to achieve there.


>what is array of void and why am I getting it in the following program?
>I cannot figure out what this array of void is.

Don't worry: nobody knows what's an array of void because no such animal in C and C++ languages ;)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.