I want to create MySQL connection in one function (file) in a C project and then use that connection globally (access it in every function or file in the project). Is that possible and what is the logic (pattern) I should follow?
Thanks!
I want to create MySQL connection in one function (file) in a C project and then use that connection globally (access it in every function or file in the project). Is that possible and what is the logic (pattern) I should follow?
Thanks!
I'm not experienced in MySQL but presumably the connection is stored in a variable after you make it, perhaps a MYSQL*. Therefore, you can just use the standard way to share global variables across files in C. See: How do I share variables between different .c files? , How do I use extern to share variables between source files?