debug assertion failed str!=NULL fprintf.c

Discussion in 'C++' started by Arti Potnis, Sep 2, 2004.

  1. Arti Potnis

    Arti Potnis Guest

    Hi,

    I have an application with a function "myfunction" that opens a file
    and writes to it using fprintf.
    This application runs on a unix (sun solaris 5.8) system.
    I connect to this application from a VB GUi on a windows 2000 system.
    The GUI invokes "myfunction".

    I get the following error:-

    "debug assertion failed str!=NULL fprintf.c"

    The check for NULL handler is in place.The code is similar to teh
    following lines:-

    FILE *fp;
    fp=fopen("myfile.txt","a");
    if (fp==NULL)
    exit(1);

    fprintf(fp,"hello");

    Since I check for the FILE handler for NULL value before executing
    fprintf,why should I get the debug assertion failed error.



    Thanks
    Arti
    Arti Potnis, Sep 2, 2004
    #1
    1. Advertising

  2. Arti Potnis wrote:
    > I have an application with a function "myfunction" that opens a file
    > and writes to it using fprintf.
    > This application runs on a unix (sun solaris 5.8) system.
    > I connect to this application from a VB GUi on a windows 2000 system.
    > The GUI invokes "myfunction".
    >
    > I get the following error:-
    >
    > "debug assertion failed str!=NULL fprintf.c"
    >
    > The check for NULL handler is in place.The code is similar to teh
    > following lines:-
    >
    > FILE *fp;
    > fp=fopen("myfile.txt","a");
    > if (fp==NULL)
    > exit(1);
    >
    > fprintf(fp,"hello");


    So, you're just printing "hello" into that file? Or is it a bit more
    complicated? Try doing exactly what you wrote here. Output "hello"
    and see if there is a difference.

    >
    > Since I check for the FILE handler for NULL value before executing
    > fprintf,why should I get the debug assertion failed error.


    If I read the assertion correctly, it's not the file pointer that is
    NULL, it's most likely the format string. Now, when you say "the code
    is similar", we cannot help you. You need to post the _actual_ code.
    But don't post all of it. Reduce it to the minimal program that does
    exhibit the said behaviour.

    Also, have you tried simply debugging your application without the VB
    GUI thing calling it? What you need to do is isolate your problem. Is
    it in the connectivity code? Is it in the UNIX program? Replace the
    connectivity part with a simple piece of code that drives the rest of
    the UNIX side and see if it makes any difference.

    Good luck!

    Victor
    Victor Bazarov, Sep 2, 2004
    #2
    1. Advertising

  3. Arti Potnis

    Howard Guest

    "Arti Potnis" <> wrote in message
    news:...
    > Hi,
    >
    > I have an application with a function "myfunction" that opens a file
    > and writes to it using fprintf.
    > This application runs on a unix (sun solaris 5.8) system.
    > I connect to this application from a VB GUi on a windows 2000 system.
    > The GUI invokes "myfunction".
    >
    > I get the following error:-
    >
    > "debug assertion failed str!=NULL fprintf.c"
    >
    > The check for NULL handler is in place.The code is similar to teh
    > following lines:-
    >
    > FILE *fp;
    > fp=fopen("myfile.txt","a");
    > if (fp==NULL)
    > exit(1);
    >
    > fprintf(fp,"hello");
    >
    > Since I check for the FILE handler for NULL value before executing
    > fprintf,why should I get the debug assertion failed error.
    >


    The problem is the string is NULL, not the file pointer. You say you're
    invoking a function in another application? If you're passing the string
    from one application to another, you need to read up how to do that safely
    on your operating system. Passing a pointer (such as a char*) will usually
    not work, because the memory from one app is often not accessible to another
    app.

    -Howard
    Howard, Sep 2, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David
    Replies:
    2
    Views:
    470
    Thomas G. Marshall
    Aug 3, 2003
  2. SorceCode
    Replies:
    2
    Views:
    3,350
    Christian Jan├čen
    Jan 26, 2004
  3. Cormac
    Replies:
    3
    Views:
    2,558
    Kevin Goodsell
    Apr 6, 2004
  4. w3r3w0lf

    debug assertion failed

    w3r3w0lf, Apr 15, 2004, in forum: C++
    Replies:
    2
    Views:
    2,550
    John Harrison
    Apr 15, 2004
  5. Stefan Ram

    str.equals(null) or str==null ?

    Stefan Ram, Jul 31, 2006, in forum: Java
    Replies:
    21
    Views:
    14,659
    Oliver Wong
    Aug 3, 2006
Loading...

Share This Page