reading file in C

Hi,
I coded a C program which reads a file and manipulates data etc. I complied and ran it on Visual C++ and it ran fine.But next time i ran it,it couldnt open the file i created the file as a text file .following is the code

infile = fopen("rdata.txt", "r");

outfile = fopen("01-14.out", "w");

any suggestions Thank you



Answer this question

reading file in C

  • Analyst

    In case the previous suggestions (make sure to close the file) doesn't solve the problem...

    Make sure the filename is correct (is it rdata.txt or 01-14.out )

    Also, the current working directory must be correct.  If your code changes it or you run your code from a different directory, you might not be able to find the file.

  • rajas

    Did u move the program from the same folder as the files

  • DotNET_Guru

    Did you add code to close the file after it is written too   It seems the files hang open in the memory and therefore can't be accessed.  Hope this helps


  • reading file in C