/* 功能:短信分割 日期:2013-05-28 */ #include<stdio.h> #include<stdlib.h> #include<string.h> #define LEN 70 #define userLEN 1000 int main(void) { char message[userLEN]={0}; char **p; int i,j,row;
printf("Please input your short message:n"); gets(message); //格式转换 row = strlen(message) / 70 + 1; p = (char**)malloc(row*4);
for (i=0;i<row;i++) {
p[i] = (char*)malloc(70*sizeof(char));
} for(i=0;i<row;i++) {
for(j=0;j<LEN;j++) { p[i][j] = message[i * 70 + j]; }
} //分割并输出短信 printf("send:n");
for (i=0;i<row;i++) { printf("%d.",i+1); for (j=0;j<LEN;j++) { printf("%c",p[i][j]); }
printf("n"); } //动态数组释放 for(i = 0;i<row;i++) { free(p[i]); } free(p);
system("pause"); return 0;
}