Time function call

Hello friends,
I have this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
char *ParseDate( char* pDate )
{

int Day;
int Year;
int Month;
int Hour;
int Min;
time_t Date;
tm NewDate;
char date_buff[40];
sscanf( pDate, "%02d/%02d/%04d %02d:%02d", &Day, &Month, &Year, &Hour, &Min );

memset( &NewDate, 0, sizeof( NewDate ) );
NewDate.tm_mday = Day;
NewDate.tm_mon = Month-1;
NewDate.tm_year = Year - 1900;
NewDate.tm_hour=Hour;
NewDate.tm_min=Min;
Date = mktime( &NewDate );
struct tm* my_tm=&NewDate;
strftime(date_buff, sizeof(date_buff), "%Y/%m/%d %H:%M", my_tm);

return date_buff;
}

int main() {
	
	char pTime[30]="23/07/2010 07:10";


cout<<ParseDate(pTime);
cin.get();
}

but I receive a scratch by calling the ParseDate function.
I wish to receive the date_buff return value in a readable form.
How I can do this?
Thanks
Last edited on
char date_buff[40]; this is a local variable.

So you must do char *data_buff;

date_buff=new char(40);

And now your date_buff is no a local variable, so you can recived ok
Hello jecaestevez,
thank you for the reply. But I don't handstand where i must put *data_buff;
and date_buff=new char(40);. I have put them in the ParseDate function, but I don't read anything in the debug window.
Regards
Topic archived. No new replies allowed.