asciiget.c 561 B

12345678910111213141516171819202122232425
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. /**************************************** MAIN *********************************************/
  4. int main(int argc,char *argv[])
  5. {
  6. FILE *fp;
  7. int c;
  8. if(argc != 2) {
  9. fprintf(stderr,"USAGE: getascii filename: where file is an ascii textfile\n");
  10. return 0;
  11. }
  12. if((fp = fopen(argv[1],"r"))==NULL) {
  13. fprintf(stderr,"Cannot open file %s for output.\n",argv[1]);
  14. return 0;
  15. }
  16. fseek(fp,0,0);
  17. do {
  18. c = fgetc(fp);
  19. fprintf(stderr,"%c %d\t",c,c);
  20. } while(c != EOF);
  21. fclose(fp);
  22. return 1;
  23. }