/***********************************************************
* Code untuk menghubungkan ke database mysql *
* created by Dony Wahyu Isp *
* Doni’X Software (www.donixsoftware.web.id *
***********************************************************/
#include <stdio.h>
#include <string.h>
#include <mysql.h>
extern char pesan_error[512];
extern int kode_error;
extern char host[32];
extern char user[32];
extern char password[32];
extern char database[32];
//MYSQL mysql;
MYSQL *koneksi_mysql (char* _host, char* _user, char* _password, char* _database, MYSQL *mysql) {
strcpy(host, _host);
strcpy(user, _user);
strcpy(password, _password);
strcpy(database, _database);
mysql_init(mysql);
return mysql_real_connect(mysql, host, user, password, database, 0, 0, 0);
}
void tutup_mysql (MYSQL *koneksi, MYSQL_RES **res) {
mysql_free_result(*res);
mysql_close(koneksi);
}
int eksekusi_sql (unsigned char* sql, MYSQL *koneksi, MYSQL_RES **res) {
int state;
int ch;
state = mysql_query(koneksi, sql);
if (state != 0) {
kode_error = 2;
strcpy(pesan_error, “nQuery Error!!!n”);
strcat(pesan_error, mysql_error(koneksi));
return 1;
}
*res = mysql_store_result(koneksi);
return state;
}
MYSQL_ROW list_mysql (MYSQL *koneksi, MYSQL_RES *res) {
return mysql_fetch_row(res);
}
http://forum.vb-bego.com/viewtopic.php?f=36&t=1547
k mau tanya klo buat modul fungsi n prosedur dlm program C++ gimana ya?
bikin modul fungsi ttg bagi, kali (hrz pake + ga boleh pale *), tambah, kurang, pangkat (hrz pake + ga boleh pake ^), mod, swap (p’tukaran)
gimana ya k?
udah coba tapi error terus..
ini codenya:
#include
#include
#include
void main ()
{
int a, b;
cout<>a;
cout<>b;
if (a 10 && b 10)
{
cout<<"masukkan kembali angka antara -10 sampai 10";
}
else
{
cout<<"hasil jumlah a + b= "<<jumlah (a,b);
cout<<"nhasil kali a * b= "<<kali (a,b);
cout<<"nhasil bagi a / b= "<<bagi (a,b);
cout<<"nhasil pangkat a ^ b="<<pangkat (a,b);
cout<<"nhasil kurang a – b= "<<kurang (a,b);
cout<<"nhasil mod a mod b=" <<mod (a,b);
cout<<"nswap a & b="<= y)
{
hitung = hitung + x;
i=i+1;
}
return hitung;}
int bagi (int x, int y)
{
int hasil;
hasil = x /y;
return hasil;}
int pangkat (int x, int y)
{
int hasil, i;
hasil=0 ;
if(y>0)
{
hasil=x ;
for(i=1;i<y;i++)
hasil=hasil*x ;
}
else if(yy;i–)
hasil=hasil*x ;
hasil=hasil*(-1);
}
else if(y==0)
hasil=1 ;
return hasil ;
}
int kurang (int x, int y)
{
int q;
q = x – y;
return q;
}
int mod (int x, int y)
{
int p;
p = x % y;
return p;}
int swap (int &x, int &y)
{
int temp;
temp = *x;
*x = *y;
*y = *temp;}
mohon bimbingannya…
k mau tanya klo buat modul fungsi n prosedur dlm program C++ gimana ya?
bikin modul fungsi ttg bagi, kali (hrz pake + ga boleh pale *), tambah, kurang, pangkat (hrz pake + ga boleh pake ^), mod, swap (p’tukaran)
gimana ya k?
udah coba tapi error terus..
ini codenya:
#include
#include
#include
void main ()
{
int a, b;
cout<>a;
cout<>b;
if (a 10 && b 10)
{
cout<<"masukkan kembali angka antara -10 sampai 10";
}
else
{
cout<<"hasil jumlah a + b= "<<jumlah (a,b);
cout<<"nhasil kali a * b= "<<kali (a,b);
cout<<"nhasil bagi a / b= "<<bagi (a,b);
cout<<"nhasil pangkat a ^ b="<<pangkat (a,b);
cout<<"nhasil kurang a – b= "<<kurang (a,b);
cout<<"nhasil mod a mod b=" <<mod (a,b);
cout<<"nswap a & b="<= y)
{
hitung = hitung + x;
i=i+1;
}
return hitung;}
int bagi (int x, int y)
{
int hasil;
hasil = x /y;
return hasil;}
int pangkat (int x, int y)
{
int hasil, i;
hasil=0 ;
if(y>0)
{
hasil=x ;
for(i=1;i<y;i++)
hasil=hasil*x ;
}
else if(yy;i–)
hasil=hasil*x ;
hasil=hasil*(-1);
}
else if(y==0)
hasil=1 ;
return hasil ;
}
int kurang (int x, int y)
{
int q;
q = x – y;
return q;
}
int mod (int x, int y)
{
int p;
p = x % y;
return p;}
int swap (int &x, int &y)
{
int temp;
temp = *x;
*x = *y;
*y = *temp;}
mohon bimbingannya…