1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Rep Power

    Embedded C MySQL client gives no output

    I'm trying to make work a C MySQL client on a Unix server/client
    environment through terminal.

    I have restricted access(username/password) to a specific database to which I
    connect with no problem using the 'mysql' cmdline tool.

    I write a simple C program ( connect/disconnect )

    #include <stdio.h>
    #include <mysql.h>
    int main( int argc, char *argv[] )
            MYSQL *db;
            printf( "just checking..." );
            db = mysql_init( NULL );
            if( mysql_real_connect( db, server, NULL, NULL, NULL, 0, NULL, 0 ) )
                    fprintf( stderr, mysql_error( db ) );
            printf( "%d\n", mysql_ping( db ) );
            mysql_close( db );
            return 0;

    I manage to successfully build and link it with gcc
    but when i execute the produced binary it gives no
    output, not even the "just checking" printf() message.

    i've posted the same question on the MySQL forum,
    but no luck.

    any suggestion would be greatly appreciated,
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Woodland Hills, Los Angeles County, California, USA
    Rep Power
    Try changing that printf( "just checking..." ); to either:
    printf( "just checking...\n" );
    fprintf(stderr, "just checking...\n");

    When your terminal is running in cooked mode (as is usually the case), it buffers input, which is why I suspect you aren't seeing the message. Hope this helps :)

IMN logo majestic logo threadwatch logo seochat tools logo