In a program I am currently working on I have a template function included in a separate .h file that reads in five columns of data from a .txt file. The data is passed to the main program and in this instance I only care about the array title "MISC_DATA". I am trying to determine the largest value in the array "MISC_DATA" and have written another function that the data has to be passed to, in order to determine this. However, the compiler is telling me that it does not recognize the function call "Maximum_Value". I am pretty sure that it is having problems with the variable MISC_DATA included in the routine call and not the function itself. Either it does not recognize MISC_DATA as an array or I have the syntax wrong. I'm only including the important snippets of code to make it more readable. The Read_Five_Columns functions works fine, it is the function "Maximum_Value", which is not being recognized by the compiler because of how the pointer array MISC_DATA is written in the main program. For clarification the variable MISC_DATA in the function call is a float which contains the array and the variable "size_Mis" is an integer which contains the array size. Any thoughts would be appreciated.
int main(int argc, const char * argv[]) {
#include "Use_RNG.h"
#include "Read_Columnar_File.h"
#include <fstream>
#include <iostream>
std::vector<std::string> str3;
std::vector<int> str4;
std::vector<char> str5;
std::vector<int> str6;
unsigned long size_Mis;
std::vector<float> MISC_DATA; // Reads in Misc. spending data
char File1[8];
strcpy(File1, "Misc.txt");
Read_Five_Columns(File1,MISC_DATA,str3,str4,str5,str6);
str3.clear(); str4.clear(); str5.clear(); str6.clear();
size_Mis = MISC_DATA.size();
float value;
value = Maximum_Value(MISC_DATA,size_Mis);
end_time = clock();
std::cout << std::endl << "Total Time: " << (end_time-start_time)/CLOCKS_PER_SEC << std::endl;
return 0;
}
int Maximum_Value(float *array,int array_size)
{
float max = 0;
for(int i =10; i < array_size-1; i++)
{
if(array[i] > max) max = array[i];
}
return max;
}
Maxmimum_Valuereturnintinstead offloat?MISC_DATAis astd::vectorand not an array or a pointer.