/*
fputs(s[],fp)函数的使用!
*/
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
FILE *fp;
if((fp=fopen("fputs.txt","w"))==NULL){
cout<<"文件打开失败:"<<endl;
return 0;
}
else
{
char s[20];
gets(s);
fputs(s,fp);
}
fclose(fp);
return 0;
}
/*fgets(s[],n,fp)函数的使用方法*/
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
FILE *fp;
if((fp=fopen("file1.txt","r"))==NULL){
cout<<"打开文件失败!"<<endl;
return 0;
}
else
{
char s[20];
fgets(s,10,fp);
cout<<s<<endl;
}
fclose(fp);
return 0;
}