Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(int argc, char *argv[])
- {
- int freq = 0;
- char text[256];
- int sum = 0;
- FILE *day1;
- if ((day1 = fopen("day1.txt", "r")) == NULL) {
- puts("File could not be found/opened");
- }
- else {
- puts("Opened, processing...");
- while (!feof(day1)) {
- fscanf(day1, "%256s", text);
- freq = atoi(text);
- sum = sum + freq;
- }
- printf("Sum of all freq is:%d ", sum);
- fclose(day1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement