#include<limits.h>
#include<stdio.h>
#define MAXLINE 1000
int getxline(char s[], int lim)
{
int c, i;
for(i = 0; i < lim-1 &&(c = getchar()) != EOF && c != '/n'; ++i)
s[i] = c;
if(c == '/n')
{
s[i] = c;
++i;
}
s[i] = '/0';
return i;
}
int len(char s[])
{
int i;
i = 0;
while(s[i] != '/0')
++i;
return i;
}
int main(void)
{
char line[MAXLINE];
int mylen;
while((mylen = getxline(line, MAXLINE)) > 0)
printf("%d/n", len(line));
}
C语言统计每行的字符数
最新推荐文章于 2021-05-17 09:00:48 发布