Writing some C code just out of curiosity and I'd like to move some values for a MySQL connection to a kind of const
.
Question 1 Is it a good idea to store host, user etc in preprocessor macros? I.e.:
#include <my_global.h>
#include <mysql.h>
#define DB_HOST "mysqlhost.com"
#define DB_USER "mysqlusername"
#define DB_TABLE "tablename"
...
To use them later like mysql_real_connect(con, DB_HOST, DB_USER, DP_PASS, DB_NAME, 0, NULL, 0) == NULL)
?
Question 2
Can I use DB_TABLE
's value inside a quoted string? I.e. mysql_query(con, "SELECT * FROM DB_TABLE")
If so - what is corrcect way to use it here?