Close
Close

I made a word file named prog.txt and typed the letter "p" into it but file display not coming up

   Ben

#include <stdio.h>
int main()
{
  FILE *fr;
  char c;
  fr = fopen("prog.txt", "r");
  while( c != EOF)
  {
    c = fgetc(fr); /* read from file*/
    printf("%c",c); /*  display on screen*/
  }
  fclose(fr);
  return 0;
}

 

The exact code used in the lesson, but I made a word doccument named prog.txt and printed p in it. Why is p not showing up?

  • reply please
    - Ben
  • Is your prog.txt is in the same folder where your code is?
    - Amit Kumar
  • No it isn’t, I used the compiler, and then made a word document. Do I need to put the word document and the compiler in a folder?
    - Ben
  • Yes, the C code and the word document must be in the same folder otherwise you need to give full path instead of just name of the file.
    - Amit Kumar

Answers

Ask Yours
Post Yours
Write your answer