c语言 windows下txt换行是/n /r 俩个字符,但为什么检测不到/r
#define_CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>voidmain(){FILE*fp=f...
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *fp = fopen("C:\\Users\\lenovo\\Desktop\\00.txt", "r");
int numf=0;
int numn=0;
int numr = 0;
char ch;
while (( ch = fgetc(fp)) != EOF)
{
if (ch == '\n')
numn++;
else if (ch == '\r')
numr++;
else if (ch == '*')
numf++;
}
printf("*=%d,\\n=%d,\\r=%d", numf,numn,numr);
getchar();
} 展开
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *fp = fopen("C:\\Users\\lenovo\\Desktop\\00.txt", "r");
int numf=0;
int numn=0;
int numr = 0;
char ch;
while (( ch = fgetc(fp)) != EOF)
{
if (ch == '\n')
numn++;
else if (ch == '\r')
numr++;
else if (ch == '*')
numf++;
}
printf("*=%d,\\n=%d,\\r=%d", numf,numn,numr);
getchar();
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询