Passing a File Handle...

This is a discussion on Passing a File Handle... within the C++ Programming forums, part of the General Programming Boards category; I tried this: void a_function(FILE *inFile); int main() { FILE *inFile; a_function(inFile); } void a_function(File *inHandle) { File *inHandle; } ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    Passing a File Handle...

    I tried this:


    void a_function(FILE *inFile);

    int main()
    {
    FILE *inFile;
    a_function(inFile);
    }

    void a_function(File *inHandle)
    {
    File *inHandle;
    }

    ...but no good!
    What I want to know is can it be done. Can a file handle be passed around like a drunk girl at a frat party?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    Well it might work, if
    - you opened the file before passing the handle to the function
    - you noticed that FILE is not the same as File (case matters)

    Oh, and please note the post at the top of the forum for guidelines on posting code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,452
    Also, is this C or C++?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

Tags for this Thread


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