0
我的结构变量temp_var[0].trade_date
的值为20100614
。我需要格式化这个日期,如6/14/2010
。有没有人可以帮我把这个日期格式化?更改日期格式C
我的结构变量temp_var[0].trade_date
的值为20100614
。我需要格式化这个日期,如6/14/2010
。有没有人可以帮我把这个日期格式化?更改日期格式C
你可以用sprintf,像这样:
//date
int numeric_date = 20110430;
//convert integer to string
char numeric_date_string[9];
sprintf(numeric_date_string,"%d",numeric_date);
//format the string
char date[11];
sprintf(date,"%.4s/%.2s/%.2s",&numeric_date_string[0], &numeric_date_string[4], &numeric_date_string[6]);
谢谢很多timesquare .. – jcrshankar 2011-04-30 04:24:04
被它存储为字符串(字符*)或INT? – MByD 2011-04-30 04:08:44