john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

file cat

/* John Pfeiffer 2010-05-17 dos version of linux "cat" */

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
    char c;    
    FILE* fp;

    if( 2 != argc )
    {    printf("wrong number of arguments, should be cat.exe filename\n");
        exit(1);
    }

    fp = fopen(argv[1],"r");

    if( fp == NULL )
    {    printf("error opening file\n");    
    }
    else
    {
        c = getc(fp);
        while( !feof(fp) )
        {
            putc( c , stdout);
            c = getc(fp);
        }    
        fclose(fp);      
    }

    return( 0 );
}/* end main */

  • « Trac wiki install plugins
  • php form to tree diagram »

Published

Jun 17, 2010

Category

c

~56 words

Tags

  • c 95
  • cat 3
  • file 92