#ifdef WIN32
#include <windows.h>
#include <winsock.h>
#pragma warning (disable: 4514 4786)
#pragma warning( push, 3 )
#endif
#include <stdio.h>
#include "mysql/mysql.h"
#ifndef WIN32
#include <unistd.h>
#endif
#include <iostream>
int main(int argc, char **argv)
{
MYSQL mysql;
printf("Ejemplo conexion mySql");
if(mysql_init(&mysql)==NULL)
{
printf("\nFailed to initate MySQL connection");
exit(1);
}
/*now you can call any MySQL API function you like*/
if (!mysql_real_connect(&mysql,"localhost","t

suari o","la_password","la_database",0,NULL,0))
/*variation #1*/
{
printf( "Failed to connect to MySQL: Error: %s\n", mysql_error(&mysql));
system("PAUSE");
exit(1);
}
printf("Logged on to database sucessfully\n");
system("PAUSE");
mysql_close(&mysql);
}