C2064 - argument error

Hello, this is my first time using this forum. I keep getting the error "term does not evaluate to a function taking 4 arguments". I do not know enough about computer sience to know what the problem could be. If i could get suggestions from someone more talented than me, on where to even look, it would be appreciated. I apologize if my code shows up messy. I am not sure how it will look when submitted. Let me know how to improve it if need be.




#include <iostream>
#include "dailyEntry.h"
#include "makeRunningAverage.h"
#include "reverseStockData.h"
using namespace std;

int runningAverage (int linesRead, dailyEntry stockTable[], dailyEntry fiftyDayAverageTable[], dailyEntry twoHundredDayAverageTable[])
{
double fiftyDaySum = 0;
double twoHundredDaySum = 0;
int linesReadForAverages= 0;

for (int i=199; i<linesRead; i++){ //loop to sum previous 50 closingIndex variable's, starting from day 200
for (int fifty=i; fifty>(i-50); fifty--){
fiftyDaySum = stockTable[fifty].closingIndex + fiftyDaySum;
}
for (int twoHundred=i; twoHundred>(i-200); twoHundred--){ //loop to sum previous 200 closingIndex variable's, starting from day 200
twoHundredDaySum = stockTable[twoHundred].closingIndex + twoHundredDaySum;
}

fiftyDayAverageTable[linesReadForAverages].closingIndex = fiftyDaySum/50; //assigning closingIndex to the average for the previous 50 days
fiftyDayAverageTable[linesReadForAverages].dateString = stockTable[i].dateString; //assigning dateString to the date the 50 day average started from

twoHundredDayAverageTable[linesReadForAverages].closingIndex = twoHundredDaySum/200; //assigning closingIndex to the average for the previous 200 days
twoHundredDayAverageTable[linesReadForAverages].dateString = stockTable[i].dateString; //assigning dateString to the date the 200 day average started from

fiftyDaySum = 0; //reseting sums and taking new count of lines stored
twoHundredDaySum = 0;
linesReadForAverages++;
//attempting to output data to see what the hell im doing
cout << fiftyDayAverageTable[linesReadForAverages].dateString << " " << fiftyDayAverageTable[linesReadForAverages].closingIndex << " \\ " << twoHundredDayAverageTable[linesReadForAverages].dateString << " " << twoHundredDayAverageTable[linesReadForAverages].closingIndex << endl;
}

return linesReadForAverages;

}
Just an fyi you want to put your code in code tags like (insert your code) . Also if you are using headers that are unique then you will want to include those as well so people can compile and test your code for maximum help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include	<iostream>
#include	"dailyEntry.h"
#include	"makeRunningAverage.h"
#include	"reverseStockData.h"
using namespace std;

int runningAverage (int linesRead, dailyEntry stockTable[], dailyEntry fiftyDayAverageTable[], dailyEntry twoHundredDayAverageTable[])
{
double fiftyDaySum = 0;
double twoHundredDaySum = 0;	
int linesReadForAverages= 0;	

for (int i=199; i<linesRead; i++){	 //loop to sum previous 50 closingIndex variable's, starting from day 200
for (int fifty=i; fifty>(i-50); fifty--){	
fiftyDaySum = stockTable[fifty].closingIndex + fiftyDaySum;
}
for (int twoHundred=i; twoHundred>(i-200); twoHundred--){	//loop to sum previous 200 closingIndex variable's, starting from day 200
twoHundredDaySum = stockTable[twoHundred].closingIndex + twoHundredDaySum;
}

fiftyDayAverageTable[linesReadForAverages].closingIndex = fiftyDaySum/50;	//assigning closingIndex to the average for the previous 50 days
fiftyDayAverageTable[linesReadForAverages].dateString = stockTable[i].dateString;	//assigning dateString to the date the 50 day average started from

twoHundredDayAverageTable[linesReadForAverages].closingIndex = twoHundredDaySum/200;	//assigning closingIndex to the average for the previous 200 days
twoHundredDayAverageTable[linesReadForAverages].dateString = stockTable[i].dateString;	//assigning dateString to the date the 200 day average started from

fiftyDaySum = 0;	 //reseting sums and taking new count of lines stored
twoHundredDaySum = 0;
linesReadForAverages++;
//attempting to output data to see what the hell im doing
cout << fiftyDayAverageTable[linesReadForAverages].dateString << " " << fiftyDayAverageTable[linesReadForAverages].closingIndex << " \\ " << twoHundredDayAverageTable[linesReadForAverages].dateString << " " << twoHundredDayAverageTable[linesReadForAverages].closingIndex << endl;
}

return linesReadForAverages;

}
Also where is the error referring to in the code and can you include your main function and the goal of the code as a whole?
Last edited on
O, ok. How do you implement these code tags, i do not see one in this reply feature. Also, my code contains 6 header files, and 6 cpp files, one of which opens a file i have stored. Should i include them all, if need be, and how would i include the file. As i was reading about the c2064 error, it was showing ppls errors of simply 'double' assigning a variable. I thought it may have just been that in this particular function, which i cannot see. I am not good enough at programming to know what all problems this could mean.
just read your second post
There is a button to click on for the code tags either on the side or the bottom where it says Format: ... The button is the one that looks like <>. The other option is to simply write [co de] and then put your code in and then finish with [/co de].

Example:

[co de]

paste your code here

[/co de]

If you remove the spaces then it will work for you.

You probably do not need to put in your full code but you can if you would like. I was also thinking it is a double assignment issue but I can't debug anything I can't see. I would say include all parts of your code that call the runningaverage function. Make sure to mention what line the error message is referring to though.
Last edited on
Yes, ok I will try to do this.
I will just put all my code. That way you can see all. They should work in the order i put them in. I think. The overall goal is to find and display when the when the data 'crosses'. It is a complex enough problem, but i dont think the error should be.

The main function:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include	<iostream>
#include	<fstream>
#include	<string>
#include	<cmath>
#include	"dailyEntry.h"
#include	"getStockData.h"
//#include	"analyzeStockData.h"						xxxxxxxxxxxxxxxxxxx
#include	"reverseStockData.h"
#include	"findCrosses.h"
#include	"makeRunningAverage.h"
using namespace std;

int main ()
{
	const int MAXTABLESIZE = 3000;			//  Maximum size of the market data table
	dailyEntry stockTable [MAXTABLESIZE];	//  Array to store the daily market entry
	double marketMean;						//  structure entries...
	double standardDeviation;
	dailyEntry linesStockValues [MAXTABLESIZE];						//xxxxxxxxxxxxxxxxxxxxxxxxx
	int runningAverage;												//xxxxxxxxxxxxxxxxxxxxxxxxx
	int findCrosses;
	int linesReadForAverages;
	dailyEntry fiftyDayAverageTable;
	dailyEntry twoHundredDayAverageTable;
	dailyEntry devilsCrosses;
	dailyEntry goldenCrosses;

	ifstream inFile;
	//string	fileName = "H:\\Visual Studio 2008\\Projects\\Lab08\\MarketData.txt";
	string	fileName = "T:\\Visual Studio 2008\\Projects\\Lab08\\MarketData.txt";   //<-------------IMPORTANT - Drive location may need to be changed

	int		linesRead = 0;

	try {
		//  Attempt to open the file for input...
		inFile.open (fileName.c_str ());

		//  Throw an exception if it fails...
		if (inFile.fail ()) {
			throw (fileName);
		}
	}
	catch (string excpt) {		//  Catch an exception on open failure
		cout << "Failed to open input file: " << endl << excpt << endl;
		return -1;
	}

	//  Process the opened file and report the information derived
	//	by getStockData ( ... )
	linesRead = getStockData (inFile, MAXTABLESIZE, stockTable);

	if (linesRead == 0) {
		cout << "No useful data extracted...  No lines read." << endl;
	} else {


runningAverage (linesRead,stockTable,fiftyDayAverageTable,twoHundredDayAverageTable);
//findCrosses (linesReadForAverages, fiftyDayAverageTable, stockTable, twoHundredDayAverageTable, devilsCrosses, goldenCrosses);


	}
	//  Close the file now that we are done with it...
	inFile.close ();

	return 0;
}



The dailyEntry header:


1
2
3
4
5
6
7
8
#include	<string>
using namespace std;


struct	dailyEntry {
	string	dateString;
	double	closingIndex;
};



The getStockData header:


1
2
3
4
#include	<fstream>
using namespace std;

int getStockData (ifstream & anInputStream, int arraySize, dailyEntry aDataTable []);



The getStockData funtion:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include	<fstream>
#include	<string>
#include	<iostream>
#include	"dailyEntry.h"
#include	"getStockData.h"
using namespace std;

int getStockData(ifstream & inFile, int maxLines, dailyEntry stockTable [])

{
	string	inputLine;
	string	marketDateToday;

	double	marketValueToday;				//  The adjusted close of the market today
	double	marketOpenToday;				//  The opening value of the market today

	int		linesRead;						//  Count data lines processed

	//  Read and ignore the first line of data containing the
	//  headers for data columns...
	getline (inFile, inputLine);
	inFile.ignore ();

	linesRead = 0;
	//  Read input data lines (up to the maximum number or until end of file is reached)
	while (linesRead < maxLines) {

		//  Read the market date
		getline (inFile, marketDateToday, ',');

		//  Stop reading if the end of the input file
		//  is encountered.
		if (!inFile.good ()) {
			break;
		}
		inFile.ignore ();				//  Read and ignore the separating comma

		inFile >> marketOpenToday;		//  Read the market open value
		inFile.ignore ();

		inFile >> marketValueToday;		//  Read and ignore today's high value
		inFile.ignore ();

		inFile >> marketValueToday;		//  Read and ignore today's low value
		inFile.ignore ();

		inFile >> marketValueToday;		//  Read and ignore today's initial closing value
		inFile.ignore ();

		inFile >> marketValueToday;		//  Read and ignore today's volume reading
		inFile.ignore ();

		inFile >> marketValueToday;		//  This is today's adjusted market close value
		inFile.ignore ();				//  Ignore the trailing newline character

		//  Use today's data if and only if the market open
		//  was not 0.0
		if (marketOpenToday != 0.0) {
			//  Save today's date and the adjusted close value in the
			//  next entry in the stockTable array...
			stockTable [linesRead].dateString = marketDateToday;
			stockTable [linesRead].closingIndex = marketValueToday;

			linesRead++;
		}
	}

	return linesRead;
}



analyzeStockData header:


void analyzeStockData(int linesRead, dailyEntry stockTable [], double & marketMean, double & standerdDeviation);


analyzeStockData function:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include	<cmath>
#include	<iostream>
#include	"dailyEntry.h"
#include	"analyzeStockData.h"

using namespace std;

void analyzeStockData(int linesRead, dailyEntry stockTable [], double & marketMean, double & standardDeviation)

{	// Settin variables for function
	double sumMarketValue = 0;
	double sumForVariance = 0;

	// Setting loop that reads and sums up the closing values in each index line in the array
	for (int i=0; i<linesRead; i++){
		sumMarketValue = stockTable[i].closingIndex + sumMarketValue;
	}
	
	// Calculating the mean of the closing values
	marketMean = sumMarketValue/linesRead;

	// Setting loop that reads and sums up the absolute value of the closing value minus the mean
	// of the closing values, all to the power of 2, for each index line in the array
	for (int i=0; i<linesRead; i++){
		sumForVariance = pow(abs(stockTable[i].closingIndex - marketMean),2) + sumForVariance;
	}

	// Calculating the standard deviation of the closing values
	standardDeviation = sqrt(sumForVariance/(linesRead - 1));

	return;
}



reverseStockData header:


void reverseStockData (int linesRead, dailyEntry astockTable[]);


reverseStockData function:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include	<iostream>
#include	"dailyEntry.h"
#include	"reverseStockData.h"
using namespace std;

void reverseStockData (int linesRead, dailyEntry stockTable [])
{
	int firstValue = 0;
	int lastValue = linesRead - 1;
	dailyEntry holdValue;

	//loop to reverse the original stockTable array from newest date first, to oldest date first
	for ( ; firstValue<lastValue; firstValue++, lastValue--){
		holdValue = stockTable [firstValue];
		stockTable [firstValue] = stockTable [lastValue];
		stockTable [lastValue] = holdValue;
	}

	return;



makeRunningAverage header:


int runningAverage (int linesRead, dailyEntry stockTable1[], dailyEntry stockTable2[], dailyEntry stockTable3[]);

There is more....

makeRunningAverage function:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include	<iostream>
#include	"dailyEntry.h"
#include	"makeRunningAverage.h"
#include	"reverseStockData.h"
using namespace std;

int runningAverage (int linesRead, dailyEntry stockTable[], dailyEntry fiftyDayAverageTable[], dailyEntry twoHundredDayAverageTable[])
{
	double fiftyDaySum = 0;
	double twoHundredDaySum = 0;							
	int linesReadForAverages= 0;							

	for (int j=199; j<linesRead; j++){					
		//loop to sum previous 50 closingIndex variable's, starting from day 200
		for (int fifty=j; fifty>(j-50); fifty--){					
			fiftyDaySum = stockTable[fifty].closingIndex + fiftyDaySum;
		}
		//loop to sum previous 200 closingIndex variable's, starting from day 200
		for (int twoHundred=j; twoHundred>(j-200); twoHundred--){	
			twoHundredDaySum = stockTable[twoHundred].closingIndex + twoHundredDaySum;
		}
		
		fiftyDayAverageTable[linesReadForAverages].closingIndex = fiftyDaySum/50;	//assigning closingIndex to the average for the previous 50 days
		fiftyDayAverageTable[linesReadForAverages].dateString = stockTable[j].dateString;	//assigning dateString to the date the 50 day average started from

		twoHundredDayAverageTable[linesReadForAverages].closingIndex = twoHundredDaySum/200;	//assigning closingIndex to the average for the previous 200 days
		twoHundredDayAverageTable[linesReadForAverages].dateString = stockTable[j].dateString;	//assigning dateString to the date the 200 day average started from
		
		//reseting sums and taking new count of lines stored
		fiftyDaySum = 0;				
		twoHundredDaySum = 0;
		linesReadForAverages++;
		
		//attempting to output data to see what the hell im doing
		cout << fiftyDayAverageTable[linesReadForAverages].dateString << "  " << fiftyDayAverageTable[linesReadForAverages].closingIndex << " \\ " << twoHundredDayAverageTable[linesReadForAverages].dateString << "  " << twoHundredDayAverageTable[linesReadForAverages].closingIndex << endl;
	}

return linesReadForAverages;



findCrosses header:


 
void findCrosses (int linesReadForAverages, dailyEntry dataTable1[], dailyEntry dataTable2[], dailyEntry dataTable3[], dailyEntry dataTable4[], dailyEntry dataTable5[]);



findCrosses function:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include	<iostream>
#include	"dailyEntry.h"
#include	"makeRunningAverage.h"
#include	"findCrosses.h"
using namespace std;

void findCrosses (int linesReadForAverages, dailyEntry fiftyDayAverageTable[], dailyEntry twoHundredDayAverageTable[], dailyEntry stockTable[], dailyEntry devilsCrosses[], dailyEntry goldenCrosses[])
{
	int g = 0;
	bool comparison = (fiftyDayAverageTable[g].closingIndex<twoHundredDayAverageTable[g].closingIndex); 

	while (g<linesReadForAverages){
		if (comparison == true){
			do{
			g++;
			}while (fiftyDayAverageTable[g].closingIndex<=twoHundredDayAverageTable[g].closingIndex);
			
		goldenCrosses[g] = stockTable[g+199];             //xxxxxxxxxxxxxxxxxxxxxxxx
		cout << "Golden Cross - Date: " << goldenCrosses[g].dateString << "	Closing Value: " << goldenCrosses[g].closingIndex << endl;
		comparison == false;
		}

		else{
			do{
			g++;
			}while (fiftyDayAverageTable[g].closingIndex>=twoHundredDayAverageTable[g].closingIndex);
			
		devilsCrosses[g] = stockTable[g+199];			//xxxxxxxxxxxxxxxxxxxx
		cout << "Devils Cross - Date: " << devilsCrosses[g].dateString << " Closing Value: " << devilsCrosses[g].closingIndex << endl;
		comparison == true;
		}
	}

	return;
}
I've only had a quick look but it looks like one issue is that in main you are declaring local variable int runningAverage and then later calling the function runningAverage (linesRead,stockTable,fiftyDayAverageTable,twoHundredDayAverageTable);. That is where the initial error is likely coming from.

From what I can see, and I have only quickly glanced at the code so bear with me if this turns out incorrect, you don't need to be locally declaring runningAverage at all and in general you shouldn't be naming a function and variable the same thing anyways. That can easily lead to user confusion not to mention compiler errors. I would delete the variable declaration and try to run the code if I were you.
Wow, that is amazing. That would have taken me days to figure out. I cant believe you found it that fast. It fixed that error, now i just get one that says ... cannot convert parameter 3 from 'dailyEntry' to 'dailyEntry []', in the main function where i am calling runningaverage. Line 90.
O, I think its in my initialization.
Can you match up the error line from your function with the line posted here it would make it easier for me.
Yes, i got it to build. Wow, thank you very much. I really appreciate the help. We'll see how the rest goes. I may be back. Thanks again.
No worries, good luck!
Topic archived. No new replies allowed.