Could you please have a look at the code and tell me the reason why it is giving me an error?

int timeDiff(std::string startDateTime, std::string endDateTime)
{
	std::string strtYYYY, strtMM, strtDD, endYYYY, endMM, endDD;
	int strtY, strtM, strtD, endY, endM, endD;

	strtYYYY = startDateTime.substr (0, 4);
	cout << "String Start Year = " << strtYYYY << endl;
	strtY = atoi(strtYYYY.c_str()); 
	cout << "int Start Year = " << strtY << endl;

	strtMM = startDateTime.substr (5, 2);
	cout << "String Start Month = " << strtMM << endl;
	strtM = atoi(strtMM.c_str()); 
	cout << "int Start Month = " << strtM << endl;

	strtDD = startDateTime.substr (8, 2);
	cout << "String Start Day = " << strtDD << endl;
	strtD = atoi(strtDD.c_str()); 
	cout << "int Start Day = " << strtD << endl;

	endYYYY = endDateTime.substr (0, 4);
	cout << "String End Year = " << endYYYY << endl;
	endY = atoi(endYYYY.c_str()); 
	cout << "int end Year = " << endY << endl;

	endMM = endDateTime.substr (5, 2);
	cout << "String End Month = " << endMM << endl;
	endM = atoi(endMM.c_str()); 
	cout << "int End month = " << endM << endl;

	endDD = endDateTime.substr (8, 2);
	cout << "String End Day = " << endDD << endl;
	endD = atoi(endDD.c_str()); 
	cout << "int End Day = " << endD << endl;

	struct tm timeinfo;
	double dif;

	timeinfo.tm_sec;
	timeinfo.tm_min;
	timeinfo.tm_hour;
	timeinfo.tm_mday;
	timeinfo.tm_mon;
	timeinfo.tm_year;

	time_t time = mktime( &timeinfo );
	dif = difftime (time); // *** it is giving me error at this line. Which two arguments (time_t) can I pass to it according to the code I have written?

	return 1; // should actually be the time difference
}

Without knowing what the error is and where the error is, no.

it is giving me an error at line 47 that mktime takes two arguments. How can I correct it?

dif = difftime (time); // *** it is giving me error at this line. Which two arguments (time_t) can I pass to it according to the code I have written?
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.