mysql.h : No such file or directory

I am using codeblocks in a windows environment.This is my c code to connect to mysql database.

/* Simple C program that connects to MySQL Database server*/
    #include <mysql.h>
    #include <stdio.h>

    main() {
      MYSQL *conn;
      MYSQL_RES *res;
      MYSQL_ROW row;

      char *server = "localhost";
      char *user = "root";
      //set the password for mysql server here
      char *password = "*********"; /* set me first */
      char *database = "Real_flights";

      conn = mysql_init(NULL);

      /* Connect to database */
      if (!mysql_real_connect(conn, server,
            user, password, database, 0, NULL, 0)) {
          fprintf(stderr, "%sn", mysql_error(conn));
          exit(1);
      }

      /* send SQL query */
      if (mysql_query(conn, "show tables")) {
          fprintf(stderr, "%sn", mysql_error(conn));
          exit(1);
      }

      res = mysql_use_result(conn);

      /* output table name */
      printf("MySQL Tables in mysql database:n");
      while ((row = mysql_fetch_row(res)) != NULL)
          printf("%s n", row[0]);

      /* close connection */
      mysql_free_result(res);
      mysql_close(conn);
    }

I hav an error popping up saying

mysql.h : No such file or directory

When is use c++ in codeblocks, including mysql.h has no issues.But when i do it using c, the above error pops up.

Answer

To use the mysql on a windows machine one has to download the mysql connector for windows. After installing it an leaving defaults, the header and lib files can be found at.

C:Program FilesMySQLConnector C++ 8.0

C:Program FilesMySQLMySQL Server 8.0

Usually you have to detect the right header and library for you and to link them properly. Please refer to this tutorial