请教函数传值问题!
pooq 2007-07-18 08:48:21 #include <time.h>
#include <stdio.h>
void getCurrentTime(char *str);
int main(){
char myTime[30];
getCurrentTime(myTime);
printf("Current time: %s\n",myTime);
return 0;
}
void getCurrentTime(char *str){
time_t now;
struct tm *timenow;
time(&now);
timenow=localtime(&now);
strftime(str,sizeof(str),"%Y%m%d%H%M%S",timenow);
}
程序如上,能编译通过,但就是实现不了预期的结果,打印出来的信息都是乱码,用数组调用函数就应该这样写啊,实在找不出错误,请达人指教.本人新手上路,希望解答能够详细一些,谢谢!