Why won't file open with this code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charles jean
    New Member
    • Jan 2011
    • 2

    Why won't file open with this code?

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    
    int main(int argc, char *argv[])
    {
        FILE* fichier = NULL;
    
        fichier = fopen("lireecrire.txt","r+");//my file is named lireecrire.txt in notepad in same folder as  my program
    
        if (fichier != NULL)
        {
            
        }
        else
        {
            
            printf("Impossible d'ouvrir le fichier lireecrire");
        }
    
        return 0;
    }
    Last edited by Niheel; Jan 18 '11, 05:09 AM.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Your code works for me. I open your file with no problem. Are you sure you have spelled the file name correctly? Are you sure of the location?

    Be sure Notepad didn't save it as lireecrire.txt. txt. I've seen that happen.

    Comment

    Working...