Ctime error C2064

Hello to everyone!
I'm using 2 file .cpp to write in a file. The first file writes the login date and the second one writes the logout date using ctime.

I have this code in both of file:
1
2
3
4
5
6
7
8
9
10
void login::admin::logout() {
	file1.open("accesslog.txt", ios::out |ios::app);
	time_t orario = time(0);
	char* stringorario = ctime(&orario);
	file1<<"logout at "<<stringorario<<" . "<<endl;
	file1.close();
	this->Hide();
	login log;
	log.ShowDialog();
}

But the compiler gives me the error C2064 only in the 2nd file..any solutions?
Can you post the full error code and what line it occurs on?
C2064 means you're using an expression as a function when you shouldn't, and I can't tell from just what you've posted where the error is.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <string>
#include <ctime>
#include <fstream>
#include "admin.h"
#include "login.h"
using namespace std; 
using namespace MySql::Data::MySqlClient;
using namespace System::Runtime::InteropServices;

fstream file1;
void login::admin::logout() {
	file1.open("accesslog.txt", ios::out |ios::app);
	time_t orario = time(0); //HERE IS THE ERROR
	char* stringorario = ctime(&orario);
	file1<<"logout effettuato alle: "<<stringorario<<" . "<<endl;
	file1.close();
	this->Hide();
	login log;
	log.ShowDialog();
}

Do you have another member in class login, or admin that is named 'time'?
This would create a naming conflict, the compiler doesn't know if you mean 'time' the member variable, or 'time' the function.

try changing line 14 to
time_t orario = std::time(0);
That way you specify the use of the time function in the std namespace.
Last edited on
Thank you! :)
Topic archived. No new replies allowed.