Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "auxiliar.h"
- int main(int argc, char *argv[]){
- if(argc==1){
- Error(EX_NOINPUT, "No hay fichero a leer");
- return EX_NOINPUT;
- }
- if (strcmp(argv[1],"-h")==0 || strcmp(argv[1],"--help")==0)
- {
- printf ("bocabajo: Uso: bocabajo [ fichero... ]\n");
- printf("bocabajo: Invierte el orden de las l´ıneas de los ficheros (o de la entrada).\n");
- return EX_OK;
- }
- FILE *file;
- char line[2048];
- int i,j;
- for (j=argc-1; j > 0; j--){
- int ch;
- int count;
- file = fopen(arv[j], "r");
- if (file==NULL){
- Error(EX_NOINPUT, "El fichero \"%s\" no puede ser leido ", argv[j]);
- return EX_NOINPUT;
- }
- fseek(fd, 0, SEEK_END);
- while (ftell(file) > 1 ){
- fseek(file, -2, SEEK_CUR);
- if(ftell(file) < 2)
- break;
- ch =fgetc(file);
- count = 0;
- while(ch != '\n'){
- line[count++] = ch;
- if(ftell(file) < 2)
- break;
- fseek(file, -2, SEEK_CUR);
- ch =fgetc(file);
- }
- for (i =count -1 ; i >= 0 && count > 0 ; i--)
- printf("%c", line[i]);
- printf("\n");
- }
- fclose(file);
- }
- return EX_OK;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement