struct Three
{
string name;
int num;
int num2;
};
constint SIZE = 10000;
Three Array[SIZE];
void swap(int *Array, int, int);
int main()
{
ifstream file("C:\\Users\\User\\Desktop\\Array.txt");
if (!file)
{
cout << "File could not be located.";
}
for (int x = 0; x < 10000; x++) //Putting them into the array
{
file >> Array[x].name;
file >> Array[x].num;
file >> Array[x].num2;
//cout << Array[x].name << " " << Array[x].num << " " << Array[x].num2 << endl; //Displaying the arrays
}
int low = 0; //First index of the list
int high = 9999; //Last index of the list
int largeIndex = 2 * low + 1;
while (largeIndex <= high)
{
if (largeIndex < high)
if (Array[largeIndex].num < Array[largeIndex + 1].num)
largeIndex = largeIndex + 1;
if (Array[low].num > Array[largeIndex].num)
break;
else {
swap(*Array, low, largeIndex);
low = largeIndex;
largeIndex = 2 * low + 1;
}
}
return 0;
}
void swap(int *Array, int first, int second)
{
int temp;
temp = Array[first];
Array[first] = Array[second];
Array[second] = temp;
}
Im having trouble passing an [] to my function I get an error.
How can i successfully pass a structure pointer array to my function?
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.