[bo][un]lingluoz[/un] 在 2008-7-29 08:43 的发言:[/bo]
用strncpy啊
strncpy(p_str_abcdef,s_dest,2) 截ab
strncpy(p_str_abcdef+2,s_dest,2) 截cd
strncpy(p_str_abcdef+4,s_dest,2) 截ef
#include
<time.h>
#include
<stdio.h>
#include <dos.h>
int
main(void)
{
time_t
t;
int i,step=0;
char result[9],ch,ch1,ch2,ch3,ch4[9],buff[5];
t
=
time(NULL);
printf("The
number
of
seconds
since
January
1,
1970
is
%ld\n",t);
printf("%lx\n",t);
printf("%c\n",t);
do
{
result[step]="0123456789ABCDEF"[t%16];
t/=16;
step++;
}while(t!=0);
result[step]='\0';
ch=strrev(result)
;
printf("the result is:%s\n",ch);
system("pause");
return 0;
}
兄弟帮忙看看,我要把我得到的16进制时间ch,每两位两位保存到一个数组中。