C language can input multiple lines of English sentences and then count the number of words and lines. How to input? What is the problem with my code?

  c++, question
int main(){
 char s[100]={0};
 char *p=s;
 int num=0,flag=0,wnum=0,line=0;
 while ((gets(s))!  =EOF) {
 if ((*p>='a'||*p<='z')||(*p>='Z'||*p<='A')) {
 wnum++;
 if (flag==0) {
 *p-=32;
 }
 flag=1;
 }
 else{
 if (flag==1){
 num++;
 flag=0;
 
 }
 if (*p=='\n'||*p=='\0') {
 line++;
 }
 
 }
 p++;
 }
 int ave=wnum/num;
 printf("Number of lines: %d\nNumber of words: %d\nAverage length of a word: %d",line,num,ave);
 }

Command+z can’t finish the input after inputting multiple lines.
What is the problem?
Is there a better way to accept multiline text?
This is the original question, I hope I didn’t misunderstand the meaning of the question …
Thank you …
图片描述

Your main problem is that eof input is wrong. Under win is ctrl z, but under mac is not, but ctrldnote is not common.