CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    38

    return a FILE parameter

    Probably it is a stupid question but I couldnt figure it out...

    If I want to pass 2 FILE * parameters to a function_A, open it there and then use it in my main function...What I should do??

    Look what I have tryed:

    int main_function()
    {
    FILE *fp;
    FILE *fp2;
    CFile_Manip Cfile_manip;

    Cfile_manip.function_A(fp, fp2); // fp is not returned !!??

    fprintf(fp, "testing") // ERROR
    }

    bool CFile_Manip::function_A( FILE *fp, FILE *fp2)
    {
    char path[100];
    char path2[100];
    fp=fopen(path, "w");
    fp=fopen(path, "w");
    }
    boh....someone would help me??
    Thanks

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: return a FILE parameter

    Maybe like this?
    Code:
    int main_function()
    {
    FILE *fp; 
    FILE *fp2;
    CFile_Manip Cfile_manip;
    
    Cfile_manip.function_A(&fp, &fp2); 
    fprintf(fp, "testing") // ERROR
    }
    
    bool CFile_Manip::function_A( FILE **fp, FILE **fp2)
    { 
    char path[100];
    char path2[100]; 
    *fp=fopen(path, "w");
    *fp2=fopen(path2, "w");
    }
    - petter

  3. #3
    Join Date
    Oct 2004
    Posts
    38

    Re: return a FILE parameter

    yes!!! it works!!

    thanks!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured