Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char *argv[]) {
- if (argc < 2) {
- printf("Usage: %s FILENAME\n", argv[0]);
- exit(1);
- }
- FILE *fp = fopen(argv[1],"r");
- int buf[2];
- if(fp == NULL){
- printf("CANNOT open file");
- exit(1);
- }
- while(1){
- int nread = fread(buf,sizeof(int),2,fp);
- if(nread < 2){
- break;
- }
- for(int j=0;j<buf[0];j++){
- fwrite((char)buf[1],sizeof(char),1,stdout);
- }
- }
- fclose(fp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement