嘗試連接到Mysql數據庫時,出現一些煩人的警告。警告C代碼(連接到Mysql數據庫)
下面的代碼:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <mysql/mysql.h>
#include <string.h>
const char* host = "localhost";
char *database="Dbis_RG";
char user_name[10];
char passwd[10];
MYSQL_ROW row;
MYSQL_RES* result;
MYSQL_FIELD* field;
int main()
{
system("clear");
printf("Insert yur user name: \n");
scanf("%s", &user_name);
printf("Insert your passwd: \n");
scanf("%s", &passwd);
MYSQL *conn;
conn = mysql_init(NULL);
/* Connection to database */
if (!mysql_real_connect(conn, host,
user_name, passwd, database, 0, NULL,CLIENT_MULTI_STATEMENTS)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(EXIT_SUCCESS);
}
printf ("Connection successful.\n");
}
事實上我得到這些警告的問題,但我不明白我怎麼能擺脫他們:
1.0.c: In function ‘main’:
1.0.c:23: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[10]’
1.0.c:26: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[10]’
非常感謝你
莫羅
Hello @Mauro!我們非常興奮,您正在參與堆棧溢出。但是,我們注意到,您在過去向我們提出了幾個問題,但沒有接受任何答案。 **你會回去接受你以前的問題的答案嗎?**你可以通過點擊綠色的選中標記來做到這一點。 –