The compiler will only scan from top to bottom, so it must know what a NUMBER is before parsing the function declaration.
This is what the compiler sees by the time it parses line 11:
1 2 3 4 5 6 7 8 9 10 11
|
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cctype>
#include<fstream>
#include<cstdlib>
using namespace std;
void sortArray(NUMBER n[],int size);
|
At this point, the compiler does not know what a NUMBER is, but you use it for your sortArray function.
Solution 1: Forward declare struct (and don't do the "typedef struct" thing, that is a C relic).
1 2 3 4 5 6 7 8 9 10 11
|
struct NUMBER;
void sortArray(NUMBER n[],int size);
struct NUMBER
{
int decimal;
char binary[50];
char octal[50];
char hexadecimal[50];
};
|
Solution 2: Define the struct before the function declaration.
1 2 3 4 5 6 7 8 9
|
struct NUMBER
{
int decimal;
char binary[50];
char octal[50];
char hexadecimal[50];
};
void sortArray(NUMBER n[],int size);
|
PS: In general, define variables in the smallest scope possible. For example, your 'temp' variable is overwritten and only used in the narrowest scope within your if-statement, so you can declare it within there instead of on line 56.
1 2 3
|
int temp = n[i].decimal;
n[i].decimal = n[j].decimal;
n[j].decimal = temp;
|
This also help you get into the habit of declaring + initializing things on the same line when possible.
PPS: You can use std::swap instead of your own swap code.
1 2 3 4 5 6 7
|
#include <algorithm>
// ...
if (n[i].decimal > n[j].decimal)
{
std::swap(n[i].decimal, n[j].decimal);
}
|