Programming Assignment #10

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

#include <stdio.

h>
#include <string.h>
#include<stdlib.h>
#pragma warning (disable : 4996)
int main(int argc, char* argv[])
{

if (argc != 3) {
printf("Usage: mycopy infile outfile");
}
else {
FILE* inptr;

if ((inptr = fopen(argv[1], "r")) != NULL) {


FILE* fptr;
int ff, i = 0;
fptr = fopen("War_of_the_Worlds.txt", "r");
if (fptr == NULL)
{
printf("ERROR");
return 0;
}
fseek(fptr, 0, SEEK_END);
ff = ftell(fptr);
while (i < ff)
{
i++;
fseek(fptr, -i, SEEK_END);
printf("%c", fgetc(fptr));
}
fclose(fptr);
}
else {
printf("File \" % s\" could not be opened\n", argv[2]);
}
fclose(inptr);
}

You might also like