#include
void output()//输出文件的内容
{
FILE *fp;
char name[40];
printf("请输入要输出的文件的名称\n");
scanf("%s",name);
if((fp=fopen(name,"r"))==NULL)
{
printf("cannot open this file\n");
}
while(!feof(fp))
{
fgets(name,31,fp);
printf("%-30s\n",name);
}
fclose(fp);
}
int main()
{
output();
return 0;
}
#include
main()
{
FILE *fp;
char buf;
int count=0;
fp=fopen("1.txt", "r");
if(fp==NULL)
{
printf("cannot open");
exit(0);
}
while(fscanf(fp, "%c", &buf)>0)
{
count++;
printf("%c", buf);
if(buf=='\n')
{
count=0;
continue;
}
if(count%30==0)
{
printf("\n");
}
}
fclose(fp);
}