dimanche 26 novembre 2017

Write a program that creates a new data file that includes only the numbers from the first file that are greater than 60

I am writing a program that creates a new data file that will take the numbers from the first file that are greater than 60 and save them to a new file.

I have began with my code but for some reason it is not saving the numbers greater than 60. I am new to programming, still learning so any help will be very much appreciated. WHAT AM I DOING WRONG!!!?? Please HELP!

#include <stdio.h>
main()
{
int y;
FILE *DATA;
DATA = fopen("RN.txt","r");
    fscanf(DATA, &y);
if (y > 60)
{
    DATA = fopen("RN.txt","w");
    fprintf(DATA, y, "");
}
printf("Finished saving file RN.txt \n");
return 0;
}

Aucun commentaire:

Enregistrer un commentaire