打包的实现

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main()
{
char tmp[128];
char tmp1[128];
char *Msg;
int len,l,l1;
memset(tmp,0,sizeof(tmp));
sprintf(tmp,"43|%s|%s","9999","6210131919881124|123456789|123456789|123456789|123456789|123456789|123456789|123456789111");
Add_Head(tmp);
return 0;
}

int Add_Head(char *p)
{
int l1,l2,l3;
char tmp1[128],tmp2[128],tmp3[128];
l1=strlen(p);
sprintf(tmp1,"%d",l1);
l2=strlen(tmp1);
sprintf(tmp3,"%d",l1+l2+1);
l3=strlen(tmp3);
if(l2==l3)
{
sprintf(tmp2,"%d|%s",l1+l2+1,p);
}
else
{
sprintf(tmp2,"%d|%s",l1+l2+1+1,p);
}
printf("l1=%d\tl1=%d\t l1=%d\n",l1,l2,l3);
//printf("the whole massage:%s \n",p);
//printf("the whole massage:%s \n",tmp2);
p=tmp2;
printf("the whole massage:%s \n",p);
return 0;
}
View Code

 

posted on 2018-11-19 15:10  末末的爸爸  阅读(45)  评论(0编辑  收藏  举报

导航