c语言 逆序 输出文件内容

来源:互联网 发布:电脑制作音乐软件 编辑:程序博客网 时间:2024/05/20 00:15
#include <stdio.h>#include <stdlib.h>#define CNTL_Z '\032'#define SLEN 50int main(void){    char file[SLEN];    char ch;    FILE *fp;    long int count,last;    puts("Enter the name of the file to be processed:");    gets(file);    if((fp=fopen(file,"rb"))==NULL){        printf("Can't open file...");        exit(1);    }    fseek(fp,0L,SEEK_END);    last=ftell(fp);    for(count=1L;count<=last;count++){        fseek(fp,-count,SEEK_END);        ch=getc(fp);        if(ch!=CNTL_Z&&ch!='\r'){            putchar(ch);    }    putchar('\n');    }        fclose(fp);    return 0;}
#include<iostream>
using namespace std;
void main()
{
 char a='\032';
 cout<<a<<endl;
 system("pause");

}

结果 是一个 向右的 箭头!


\n 换行   将光标移动到下一行第一格   相当于平时用的回车 \r 回车   将光标移动到当前行第一格