Thread: File

  1. #1
    Deleted Account
    Join Date
    Mar 2005
    Posts
    57

    File

    This is my problem, I accidently deleted one of my files and now I forgot how to do one of the parts

    FILE *name

    name = fopen(argv[1], "r");

    now i want to pass name into say function(char *file), how do i do this?

    thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Same as any other variable type

    function(FILE *file);

    Then
    name = fopen(argv[1], "r");
    function( name );
    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.

  3. #3
    Deleted Account
    Join Date
    Mar 2005
    Posts
    57
    ^ you can't do that, the function is not a FILE pointer

    don't worry ppl, i found out how to...

    i need to read line by line using fgets and pass them into the function

  4. #4
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    now i want to pass name into say function(char *file), how do i do this?

    function(FILE *file);
    Quote Originally Posted by vdk_au
    ^ you can't do that, the function is not a FILE pointer
    what do u mean fucntion is not FILE pointer. your question was how to pass a file pointer to the fucntion, and salem posted you the right.

    ssharish2005

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > you can't do that, the function is not a FILE pointer
    Here's a tip - ask the question you meant to ask.

    We can't help you if you just post random lines of code like bazarro and expect us to see deep into the crystal ball to figure out what your real question is.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  4. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM