SHARE
TWEET

Untitled

jfan14 Sep 20th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[]) {
  5.   if (argc < 2) {
  6.     printf("Usage: %s FILENAME\n", argv[0]);
  7.     exit(1);
  8.   }
  9.   FILE *fp = fopen(argv[1],"r");
  10.   int buf[2];
  11.  
  12.   if(fp == NULL){
  13.     printf("CANNOT open file");
  14.     exit(1);
  15.   }
  16.   while(1){
  17.     int nread = fread(buf,sizeof(int),2,fp);
  18.     if(nread < 2){
  19.       break;
  20.     }
  21.  
  22.     for(int j=0;j<buf[0];j++){
  23.       fwrite((char)buf[1],sizeof(char),1,stdout);
  24.     }
  25.   }
  26.  
  27.  
  28.   fclose(fp);
  29.   return 0;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top