c语言fgets函数用法
发布时间: 2023-06-19 18:57:15
① c语言文件操作中fgets函数的使用
#include<stdio.h>
#include<string.h>
//#pragmawarning(disable:4996)
constintMAXLEN=1000;
intmain(){
chars[MAXLEN];//={0};
//memset(s,0,sizeof(s));//s要被多次使用的
FILE*p=fopen("E:\输入信息得文本.txt","w");
if(p==NULL){
printf("不能打开文件。 ");
return1;
}
while(1){
//gets(s);
fgets(s,MAXLEN,stdin);
//fgtes()函数读取的串中通常含有' '
intlen=strlen(s);
if(s[len-1]==' ')s[len-1]='