#include
#include
#include
int main()
{
FILE *fp;
char str[256];
if((fp=fopen("d:\\1.txt","r"))==NULL)
{
printf("不能打开文件!\n");
exit(0);
}
while(1)
{
if(feof(fp))break;
fgets(str,256,fp);
printf("%s",str);
}
printf("已读取完!\n");
}
我写的比较简单能懂的
-物联网校企联盟技术部
#include
#include
#define N 100
#include
int main()
{
FILE *fp;
int i,j=0,k;
char s[N][10],temp[10];
if((fp=fopen("d:\\1.txt","r"))==NULL)
{
printf("Source file can\'t be opened!\n");
system("pause>nul");
exit(0);
}
for(i=0;!feof(fp);i++)fscanf(fp,"%s",s[i]);
k=i;
for(i=0;i
for(j=i+1;j
{
strcpy(temp,s[i]);
strcpy(s[i],s[j]);
strcpy(s[j],temp);
}
}
for(i=0;i
采纳我哦