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?