Writing to files from outside the function they were opened in

This is a discussion on Writing to files from outside the function they were opened in within the C++ Programming forums, part of the General Programming Boards category; Is there any way of doing this? I need to open up an output text file in the main function ...

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

    Writing to files from outside the function they were opened in

    Is there any way of doing this?

    I need to open up an output text file in the main function (where argv is) and then write to it from within a function called by main, yyparse(void). This function is generated by bison and I don't know any way of adding parameters to it.

    Any help would be appreciated,

    Felix

  2. #2
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Well the 'right' way of doing it would involve adding parameters to your yyparse function. You need to pass the file descriptor so the function knows about it.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very slow file writing of 'fwrite' function in C
    By scho in forum C Programming
    Replies: 6
    Last Post: 08-03-2006, 03:16 PM
  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. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 09:44 AM
  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