给你一个函数吧 只是一行的,你自己再改一下就得了
//12、统计单词数和字符数,以空格计,以'.'结束 ,
#include<stdio.h>
#define N 100
main()
{
char a[N];
int i,k,op; //k will be words's number.
//i will be chars's number
i=op=0,k=1; //op to flag those more than one space
//which used to separate words
printf("a line:\n");
gets(a);