fopen() in c returns null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lakshmi1
    New Member
    • May 2007
    • 3

    fopen() in c returns null

    why fopen returns null,is there any specific reason
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    HI,
    In which mode r u opening the file
    Check the path of the file,being passed as argument
    This may be the reason , for which fopen returns null

    Thanks
    Raghuram

    Comment

    • lakshmi1
      New Member
      • May 2007
      • 3

      #3
      Originally posted by gpraghuram
      HI,
      In which mode r u opening the file
      Check the path of the file,being passed as argument
      This may be the reason , for which fopen returns null

      Thanks
      Raghuram

      Hi,

      I am opening file in write mode.Path contains a very big string.
      Several files were copied into the same path,but suddenly for one of the file
      it is not able to write into the same path

      Thanks,
      srilakshmi

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        Hi,
        I think there is a restriction to path size of 260 characters.(I am not very sure abt this)
        Check for the failing fopen the path is greater than 260 characters.
        This value is in stdio.h

        Thanks
        Raghuram

        Comment

        • ilikepython
          Recognized Expert Contributor
          • Feb 2007
          • 844

          #5
          Originally posted by gpraghuram
          HI,
          In which mode r u opening the file
          Check the path of the file,being passed as argument
          This may be the reason , for which fopen returns null

          Thanks
          Raghuram
          Also, dont' forget that if the file isn't there or fopen() can't open it, it will return null as well. You should always check after you open a file, to see if it returned null or the actual file pointer.

          Comment

          • AdrianH
            Recognized Expert Top Contributor
            • Feb 2007
            • 1251

            #6
            Also check the errno value.


            Adrian

            Comment

            • Silent1Mezzo
              New Member
              • Feb 2007
              • 208

              #7
              Originally posted by ilikepython
              Also, dont' forget that if the file isn't there or fopen() can't open it, it will return null as well.
              fopen() in write mode will create the file if it doesn't exist.

              Comment

              • ilikepython
                Recognized Expert Contributor
                • Feb 2007
                • 844

                #8
                Originally posted by Silent1Mezzo
                fopen() in write mode will create the file if it doesn't exist.
                Yep, that is also true.

                Comment

                Working...