0

I am working in Ansi C, windows platform. I want to attach mysql database to my c program. Kindly guide me how I can make it possible.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Siddiqui
  • 7,662
  • 17
  • 81
  • 129

2 Answers2

4

Here is a working example which sets up a connection and performs a query.

stacker
  • 68,052
  • 28
  • 140
  • 210
  • Thanks Stacker for your link.. Actually i working on window platform and I have wamp server for mysql database, I there any way to connect my c application with wamp server. – Siddiqui Jan 25 '10 at 08:15
  • The source code is the same on windows, you just need to compile it differently - which is pretty much just a matter of setting include paths and libraries to link to. – nos Jan 25 '10 at 08:41
0

ANSI (ISO) C doesn't do networking, so by definition you can't do MySQL connections in ANSI C. You will have to move to POSIX at least. So, the answer is, "It is impossible."

Alok Singhal
  • 93,253
  • 21
  • 125
  • 158
  • I widows platform which lib I have to include instead of POSIX? – Siddiqui Jan 25 '10 at 08:17
  • @Arman: you will need MySQL C library: http://dev.mysql.com/doc/refman/5.0/en/c.html. But your question mentioned ANSI C. You can't do it in ANSI C, although I don't know if you really require ANSI C or you just said that without understanding what it meant. Go to http://dev.mysql.com/downloads/connector/c/#downloads and download the windows version for the library, and read their documentation. – Alok Singhal Jan 25 '10 at 08:19
  • I know POSIX is not the standard library, I want to use standard libraries, but in those cases in which ANSI doesn't support, I have to go to other libraries which is non-standard. – Siddiqui Jan 25 '10 at 09:25
  • For writing MySQL client code in C, the MySQL C libraries are going to be the most portable. They are available for a variety of systems. – Alok Singhal Jan 25 '10 at 09:31