Where are my errors in this code?

Hi,
I'm trying create a function to connect to my database "MyAgenda", but, the compiler print this error:

andre@Andre:~$ gcc banco.c -o banco
banco.c: In function ‘CriaConexao’:
banco.c:7:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
banco.c:13:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
banco.c:28:1: error: expected ‘{’ at end of input



My code is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <mysql/mysql.h>

void CriaConexao(char* host, char* usuario, char* senha, char* banco)

int main()
{
	CriaConexao("localhost", "root", "", "MyAgenda");
	return 0;
}

void CriaConexao(char* host, char* usuario, char* senha, char* banco)
{
	MYSQL conexao;
	mysql_init(&conexao);
	
	if(mysql_real_connect(&conexao, host, usuario, senha, banco, 0, NULL, 0))
	{
		printf("Conectado com sucesso!\n");
		return 0;
	}
	else
	{
		printf("Falha ao se conectar ao banco!\n");
		printf("Erro %d : %s\n", mysql_errno(&conexao), mysql_error(&conexao));
		return 1;
	}
}


What is wrong on my code?

I'm using MySQL.

Thanks.
Missing a semicolon ; on line 4 after your prototype.
Oh, it's really. And missing too a flag in gcc: -lmysqlclient

Thank you.
Topic archived. No new replies allowed.