Thread: Basic text file encoder

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Personally, I think you should just open the two files in main() and then pass them to the other functions.

    If you really badly want to do it the other way, then you have to create a regular FILE * in main() and pass it's address via the & operator.

    Edit: Another alternative is to make your read and write functions return a FILE * instead of accept one. That way in main() you can just do something like:

    Code:
    int main(void)
    {
    	FILE *in = readFile(...);
    	...
    }
    
    ...
    
    FILE *readFile(char determin)
    {
    	...
    }
    If the function readFile() fails, you can return NULL. Then inside main(), you can check the value of the FILE * returned and see if there was an error by whether or not it's NULL.
    Last edited by MacGyver; 05-22-2007 at 12:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. checking values in a text file
    By darfader in forum C Programming
    Replies: 2
    Last Post: 09-24-2003, 02:13 AM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM