Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. char* filename = "energy.txt";
  4. char str[1000];
  5. FILE *fp;
  6.  
  7. int main (void){
  8.     fp = fopen(filename, "r");
  9.     readFile();
  10.     return 0;
  11. }
  12.  
  13. void readFile(){
  14.     if (fp == NULL){
  15.         printf("Could not open file %s",filename);
  16.         return 1;
  17.     }
  18.     while (fgets(str,1000, fp) != NULL)
  19.         printf("%s", str);
  20.     fclose(fp);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement