Tanya shankar
Tanya shankar

Reputation: 11

File handling in c program to read integers

This is my code. This does not produce any output and does not even error. Can anyone please explain why?

#include <stdio.h>

int main() {
  FILE *ptr = NULL;
  ptr = fopen("numbers.txt", "r");

  int i;
  int numberArray[6];

  for (i = 0; i <5; i++) {
    fprintf(ptr, "%d ", numberArray[i]);
  }

  fclose(ptr);
}

Upvotes: 0

Views: 72

Answers (0)

Related Questions