Create mysql database tables in batches using gcc

Source: Internet
Author: User
Tags mysql host
File1my. c prepare MySQLDatabaseCreate1132001.NetkillerChen -------------------------------------------------- # include # includemain () {charhost [16]; mysqlhostadd

File 1 my. c // ------------------------------------------------------ // MySQL Database Create 1/13/2001. Netkiller Chen // #include # include main () {char host [16]; // mysql host add

File 1

My. c
//--------------------------------------------------------
// MySQL Database Create 1/13/2001. Netkiller Chen
//--------------------------------------------------------
# Include
# Include
Main ()
{
Char host [16]; // mysql host address.
Char sid [15]; // root user name.
Char pwd [15]; // root password.

/* Char * table_file [] = {
"Gsxx ",
"Bcxx ",
"Fgxx ",
"Hmbxx ",
"Ltxx ",
NULL
};*/
// Char * mysql;
Char mydatabase [256];
Char mysqltable [256];
Int I;
Int max_table_num;
Int db, status;
I = 0;
Max_table_num = 4; // max_table_num

System ("clear ");
Showme (); printf ("\ n ");

Printf ("MySQL host:"); scanf ("% s", host );
Printf ("Root user:"); scanf ("% s", sid );
Printf ("Password:"); scanf ("% s", pwd );
Printf ("Loading... \ n ");
While (table_file [I]) {
Sprintf (mydatabase, "echo \" create database % s \ "| mysql-h % s-u % s-p % s", table_file [I], host, sid, pwd );
Sprintf (mysqltable, "mysql-h % s-u % s-p % s <% s. SQL ", host, sid, pwd, table_file [I], table_file [I]);
Db = system (mydatabase );
Status = system (mysqltable );
// Printf ("% s \ n % s", mydatabase, mysqltable );
Printf (table_file [I]);
// Printf ("% d", status );
If (db = 0 & status = 0 ){
Printf ("\ t \ tInstall [OK] \ n ");
} Else {
Printf ("\ t \ tInstall [:(] \ n ");
}
I ++;
}
Address ();
}

// ------------------- Function ------------------
Showme ()
{
Printf ("------------------------------------------------------------------- \ n ");
Printf ("\ tI am Netkiller Chen. \ n ");
Printf ("\ tI am a programmer and system & net manager. \ n ");
Printf ("\ tI am gglad to be friend with you! \ N ");
Printf ("------------------------------------------------------------------- \ n ");
}
Address ()
{
Printf ("\ n ---------------------------------- \ n ");
Printf ("| \ tnewtech@sina.com | \ n ");
Printf ("| \ tOICQ: 13721218 | \ n ");
Printf ("| \ t 1/13/2001 | \ n ");
Printf ("---------------------------------- \ n ");
}

File 2
Table. h
Char * table_file [] = {
"Alxx ",
"Bcxx ",
"Fycx ",
"Fyxwxx ",
"Fyzxxx ",
"Hwzx ",
"Lhzxxx ",
"Xxdexx ",
"Xxdsxx ",
"Xxfgxx ",
"Xxglxx ",
"Xxgsxx ",
"Xxhmbxx ",
"Xxhtxx ",
"Xxjbxx ",
"Xxltxx ",
"Xxzwxx ",
"Xxzx ",
NULL
};
Some programs can facilitate table creation... Contact me if you have any questions.
The program does not count as much ..... However, some questions about batch table creation are also solved.
This program can be used as a reference for gcc beginners, because it is as simple as hello world. It also includes pointers, arrays, file inclusion, and NULL.

Put two files in the user method. /Root/mygcc/, name the pre-built mysql statement file, file name xxxx. SQL, and
# Gcc my. c-o my
# My
... No, I'm talking about it, right?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.