i want to get time and date singly and cast in to array i have peroblem to cast in array ,unsigned int new_date= date(d,m,y) is true??
cout<<new_date<<endl; isnt display current date...memcpy(write,&new_date,sizeof(int)) is true?;
using namespace std;
int date(int &Day, int &Month, int&Year) {
time_t currentTime;
struct tm *localTime;
int Hour = localTime->tm_hour;
int Min = localTime->tm_min;
int Sec = localTime->tm_sec;
return (0);
}
int main() {
int d,m,y;
unsigned int new_date=date(d,m,y);
char write[4];
memcpy(write,&new_date,sizeof(int));
int h,m,s;
unsigned int new_time=time(h,m,s);
char wrt[4];
memcpy(wrt,&new_time,sizeof(int));
1. Please use code tags! (inc. going back an editing you opening post, so anyone who reads this thread in the future can see what's going on better!) And ensure your code is well formatted (indent, spacing, etc.)
2. The code you posted doesn't compile. You say cout<<new_date<<endl; isn't displaying the current date, but as it stands the code won't even compile!
3. Then...
i want to get time and date singly and cast in to array
Cast in to an array for what purpose?
i have peroblem to cast in array ,unsigned int new_date= date(d,m,y) is true??
If you're asking if this the correct way to do it, the answer is no.
cout<<new_date<<endl; isnt display current date...
Hardly surprising as new_date is an int which you've set to the value of 0.
memcpy(write,&new_date,sizeof(int)) is true?;
If you mean, is this the right way to do it. The answer is no.
I have to admit I don't get what you're trying to do. If you're trying to display the date (possible, given you're using cout) then check out strftime() http://www.cplusplus.com/reference/ctime/strftime/
If you want people to help you with your problem, don't put barriers in their way!