Hello every one.I coded a program to print current date and time.
First I declare a function tim() to calculate the current time.
It works well.But the problem is I cant call the function from main() function.It doesnt print any thing.What is wrong with this code?
Please help me.Thanks very much!
here is my code.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
char* tim()
{
struct tm *d;
time_t now;
char li[50];
char* temp;
time(&now);
d=localtime(&now);
memset(li,'\0',sizeof(li));
strftime(li,50,"%Y.%m.%d.%H.%M.%S",d);
temp =li;
// printf("time now:%s\n",temp);
return temp;
}
int main()
{
char* array;
array=tim();
printf("Time:%s\n",array);
}
end quote.
Again - within the space of 24 hours you ignore advice about formatting your code correctly, You are extremely lucky there are good folks on this forum who are still prepared to help you.
Since you missed it the last time - READ THIS POST:
http://www.daniweb.com/forums/thread93280.html