Mailing List Archive



Back to the month index Back to the list index

Joel Bremson (jbremson@well.com)
Sun, 11 Apr 1999 23:06:13 -0700 (PDT)


Date: Sun, 11 Apr 1999 23:06:13 -0700 (PDT)
From: Joel Bremson <jbremson@well.com>
Subject: C API question
Message-ID: <Pine.GSO.4.10.9904112252290.397-100000@well.com>

Hi,

I am a novice C programmer trying to figure out how
to use the C API. I am running msql 2.08 on Red Hat 4.2 (2.0.30).

I don't understand why msqlStoreResult is outputing an integer.

[[joel@localhost c]$ gcc -c -I/usr/local/Hughes/include sql.c
msql.c: In function `main':
msql.c:39: warning: assignment makes pointer from integer without a cast

The int that was output from msqlStoreResult was something like 139700.
When I set the output variable to be an int there were no complaints
from the compiler.

Here is the code:
----------------

#include <stdio.h>

int main()
{

        int connect, db, status;
        extern char msqlErrMsg[];
        extern struct m_result *ptr;

        printf("connecting\n");

        connect = msqlConnect(NULL);
        if (connect == -1)
        {
                puts(msqlErrMsg);
                exit(1);
        }

        printf("%d - connect\n", connect);

        db = msqlSelectDB(connect, "jb");
        if (db == -1)
        {
                puts(msqlErrMsg);
                exit(1);
        }

        printf("%d - db\n", db);

        status = msqlQuery(connect, "select * from test");

        printf("%d - status\n", status);

        ptr = msqlStoreResult();

}
--------------------

Is there some sample code that would show me how the functions work?

Thanks in advance,
-Joel