L
learning_C++
I programmed this code with a function "get_current_time" in the
begining. When I compiled with the command g++ -Wall -g xxx.xpp -o xxx
there are so many errors.
please help me and thanks,
#include <map>
#include <iostream>
#include <iomanip>
#include <string>
#include <time.h>
//using namespace std;
string get_current_time(){
string timestr;
time_t rawtime;
struct tm * timeinfo;
time_t time ( &rawtime );
timeinfo = localtime ( &rawtime );
timestr=asctime(timeinfo);
}
bank.cpp:14: error: invalid conversion from `time_t*' to `int'
bank.cpp:15: error: ISO C++ forbids declaration of `timeinfo' with no
type
bank.cpp:15: error: conflicting types for `int timeinfo'
bank.cpp:13: error: previous declaration as `tm*timeinfo'
bank.cpp:16: error: ISO C++ forbids declaration of `timestr' with no
type
bank.cpp:16: error: invalid conversion from `int' to `const tm*'
bank.cpp:16: error: invalid conversion from `char*' to `int'
bank.cpp:17: error: parse error before `}' token
begining. When I compiled with the command g++ -Wall -g xxx.xpp -o xxx
there are so many errors.
please help me and thanks,
#include <map>
#include <iostream>
#include <iomanip>
#include <string>
#include <time.h>
//using namespace std;
string get_current_time(){
string timestr;
time_t rawtime;
struct tm * timeinfo;
time_t time ( &rawtime );
timeinfo = localtime ( &rawtime );
timestr=asctime(timeinfo);
}
bank.cpp:14: error: invalid conversion from `time_t*' to `int'
bank.cpp:15: error: ISO C++ forbids declaration of `timeinfo' with no
type
bank.cpp:15: error: conflicting types for `int timeinfo'
bank.cpp:13: error: previous declaration as `tm*timeinfo'
bank.cpp:16: error: ISO C++ forbids declaration of `timestr' with no
type
bank.cpp:16: error: invalid conversion from `int' to `const tm*'
bank.cpp:16: error: invalid conversion from `char*' to `int'
bank.cpp:17: error: parse error before `}' token