I am a beginner in programming, so bear with me. I keep getting an error for this code saying:

error C2664: 'activity' : cannot convert parameter 1 from 'char' to 'client_activity []'

I am testing here to see if my function will pass the array back to main() so that I can call the function correctly. I don't know if I am declaring the arrays in the wrong places or if I am using the function parameters incorrectly. Thanks for any help!

#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<fstream>

using namespace std;


struct client_activity
{
	char action;
	string name;
	int amount;

};

 void activity(client_activity activites[]);


int main()

{

	ifstream past_loans, days_activity;
	ofstream current_loans, donfile, michaelfile, sonnyfile;
	client_activity activities[19];

//	past_loans.open("past_loans.txt");
	//days_activity.open("days_activity");

	
	
   cout << activity(activities[0].action) << endl;
	




	return 0;
}
	
 void activity(client_activity activites[])
 {  
	 ifstream days_activity;
	 days_activity.open("days_activity");

	client_activity activities[19];



	activities[0].action= 'p';
	 
	 


	while (!days_activity.eof())
	{
		





	}


}

What is the type of your parameter in the call: activities[0].action ? Isn't this a single character? The function itself doesn't want a character as a parameter. What does it need?

What is the type of your parameter in the call: activities[0].action ? Isn't this a single character? The function itself doesn't want a character as a parameter. What does it need?

The type should be client_activity, which is my struct. Eventually, I want to read in data in the function and store it in the array activities[] which is of the client_activity type.

activities[0].action is a char
activities[0] is a client_activity
activities is an array of type client_activity

The function activity is declared like this:

void activity(client_activity activites[]);

Which of the above three could be passed to activity()? If you don't want that type of object forwarded to activity() what do you need to do?

Edited 6 Years Ago by Lerner: n/a

This article has been dead for over six months. Start a new discussion instead.