Thread: fputs and fprintf

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    1

    Red face fputs and fprintf

    Hallo,
    i'm trying to write in a file using the function fputs.
    fputs creates the file but does'nt write. The code works on a windows-plattform.

    if( (out=fopen(ofile, "a")) != NULL)
    {
    if(fputs(bufferHelp, out) == EOF)
    {
    printf("ERROR: could'nt write %s\n", out);
    }
    }
    else
    {
    printf("ERROR: unable to create %s\n", ofile);
    _exit(1);
    }

    Writing the stream to stdout works. But i can't write in the file out (any filename given by the commandline). I alwys get an empty file, thats all. Fprinf gives the same result.
    Thanks a lot for help in advance.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    If you post your entire code, I might be able to give you a hand.

    starX
    www.axisoftime.com
    ---------------
    starX
    www.axisoftime.com

  3. #3
    Unregistered
    Guest

    Thanks

    Thanks for your offer.
    I found the error. I did'nt close the File.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Almost Daily Contest Details
    By Prelude in forum Contests Board
    Replies: 29
    Last Post: 09-19-2004, 10:32 PM
  2. fprintf works in one function but not in the other.
    By smegly in forum C Programming
    Replies: 11
    Last Post: 05-25-2004, 03:30 PM
Website Security Test