Skip to content

Instantly share code, notes, and snippets.

@pat36
Created May 21, 2017 20:23
Show Gist options
  • Save pat36/d991eda0c270ed823a5d83c274c6157c to your computer and use it in GitHub Desktop.
Save pat36/d991eda0c270ed823a5d83c274c6157c to your computer and use it in GitHub Desktop.
My simple implementation of cat program
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
if(argc != 2) return -1;
FILE* fp;
char c;
fp = fopen(argv[1], "r");
while((c = getc(fp)) != EOF)
printf("%c", c);
fclose(fp);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment