如何用C语言,读取文件 输出每行只有一个单词

[复制链接]
查看11 | 回复1 | 2012-1-14 14:24:42 | 显示全部楼层 |阅读模式
#include #include "string.h"void main(){int i,n=0;char a[2000][25]={0};FILE *fp;/* 读全部单词,假设文件名为test.txt */ if((fp=fopen("test.txt","rt"))==NULL) {printf("不能打开 test.txt文件\n");return; }while(!feof(fp)){
fscanf(fp,"%s",a[n]);
n++; } fclose(fp);for(i=0;i<n;i++)
printf("%s\n",a...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行