Calling function a function to do fopen

This is a discussion on Calling function a function to do fopen within the C Programming forums, part of the General Programming Boards category; Hi, I'm having some troubles with openning a file that I need to read. I think it's because I'm handling ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    27

    Calling a function to do fopen

    Hi, I'm having some troubles with openning a file that I need to read. I think it's because I'm handling the FILE* wrong or something. But I'm a little confused about this. Hopefully someone can clarify it a bit for me please.

    Basically I have a function that I call from a calling function in another source file to open a ttext file. I've got all the extern stuff working so that it compiles and all. The relevant part for my open file function is below.
    Code:
    int Open (FILE** FileStream) {
    .
    .
    *FileStream = fopen (/*path and mode here*/);
    .
    .
    }
    In my calling function, I declare a FILE* variable and pass it to Open like so.

    FILE* FileStream;
    int i;

    i = Open (&FileStream);

    But when I run the program, it says can't open the file. So what exactly is wrong with the way I'm passing the FileStream to the Open function? Thanks a lot for your help.
    Last edited by fanoliv; 06-19-2006 at 02:28 PM.

  2. #2
    Registered User
    Join Date
    Jun 2006
    Posts
    27
    Sorry to bother you guys. I figured out the problem is in another part of the program, which I was passing the wrong file name to fopen. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 28
    Last Post: 07-17-2006, 12:35 AM
  2. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 09:56 AM
  3. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 07:44 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21