求大神指正我错在哪
#include<stdlib.h>#include<stdio.h>
int main(void)
{
char a[200];
char b[70],c[70],d[70];
int i,j,k,l=0;
printf("Please input your short message:\n");
gets(a);
l=sizeof(a)/sizeof(a[0]);
if(0<l<=70)
{
for(j=0;j<l;j++)
{
b[j]=a[j];
}
}
if(70<l<=140)
{
for(j=0,k=70;k<l;j++,k++)
{
c[j]=a[k];
}
}
if(140<l<=200)
{
for(j=0,k=140;k<l;j++,k++)
{
d[j]=a[k];
}
}
printf("send:\n");
if(0<l<=70)
{
printf("1.");
puts(b);
}
if(70<l<=140)
{
printf("\n");
printf("2.");
puts(c);
}
if(140<l<=200)
{
printf("\n");
printf("3.");
puts(d);
}
system("pause");
return 0;
}
作业要求:
手机可以收发的短信都以70字为限,当用户编写超过70字的短信发送时,手机系统将信息自动分割为70字(不满70也算一条)一条的短信,请模拟该功能编写程序
运行效果:
Please input your short message:
I know you can do it, but you failed at least. Now you have worked for three years and earn much money, and buy a house.
send:
1. I know you can do it, but you failed at least. Now you have worked for
2. three years and earn much money, and buy a house.
请按任意键继续_