fputs and fprintf

This is a discussion on fputs and fprintf within the Linux Programming forums, part of the Platform Specific Boards category; Hallo, i'm trying to write in a file using the function fputs. fputs creates the file but does'nt write. The ...

  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, 11: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, 04:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21