1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /*
- * Copyright (C) 2020, 2019, 2018, 2017 Girish M
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- */
- /*
- Problem statement: https://www.isical.ac.in/~pdslab/2017/exams/labtest1.pdf
- */
- #include "common.h"
- int main(int argc, char* argv[])
- {
- if(argc == 3)
- {
- FILE* fptr;
- int c, num_bytes = 0;
- if((fptr = fopen(argv[2], "r")))
- {
- while((c = fgetc(fptr)) != -1)
- {
- num_bytes++;
- if((num_bytes % atoi(argv[1])) == 0)
- {
- printf("\n");
- }
- else
- printf("%.2X ", c);
- }
- printf("\n");
- fclose(fptr);
- }
- else
- printf("\nCould not open %s\n", argv[2]);
- }
- else
- printf("\nUsage: ./cs1713-test1-bonus.o num_bytes fileName\n");
- return 0;
- }
|