1. 程式人生 > >打包的實現

打包的實現

#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