C
ctara_shafa
Hi,
I have a following problem: I'm creating a list and one of the fields
should contain the date. Firstly I ask the user for the year, month and
day and then I'd like to collect all this data in one field. To do this
I tried to concatenate those 3 numbers into one using strcat. A piece
of code is as follows
/*function to enter the date*/
char * date (void)
{
long year; /* it must of a long type */
long month; /* because of some other reasons*/
long day;
char *str1;
char *str2;
char *str3;
char *str4;
/*here are the functions collecting the data from the input*/
str1 = strcat (year,'-');
str2 = strcat (str1, month);
str3 = strcat (str2,'-');
str4 = strcat (str3,day);
return str4;
}
I think the result should be "year-month-day".. Why it doesn't work?
I have a following problem: I'm creating a list and one of the fields
should contain the date. Firstly I ask the user for the year, month and
day and then I'd like to collect all this data in one field. To do this
I tried to concatenate those 3 numbers into one using strcat. A piece
of code is as follows
/*function to enter the date*/
char * date (void)
{
long year; /* it must of a long type */
long month; /* because of some other reasons*/
long day;
char *str1;
char *str2;
char *str3;
char *str4;
/*here are the functions collecting the data from the input*/
str1 = strcat (year,'-');
str2 = strcat (str1, month);
str3 = strcat (str2,'-');
str4 = strcat (str3,day);
return str4;
}
I think the result should be "year-month-day".. Why it doesn't work?