gcc批量建mysql库表
2007-11-11 16:33:39 来源:WEB开发网核心提示:作 者: 陈景峰 file 1 my.c // // MySQL(和PHP搭配之最佳组合) Database Create 1/13/2001. Netkiller Chen // #include <stdio.h> #include </root/mygcc/table.h> main()
作 者: 陈景峰
file 1
my.c
//--------------------------------------------------------
// MySQL(和PHP搭配之最佳组合) Database Create 1/13/2001. Netkiller Chen
//--------------------------------------------------------
#include <stdio.h>
#include </root/mygcc/table.h>
main()
{
char host[16]; //MySQL(和PHP搭配之最佳组合) host address.
char sid[15]; //root user name.
char pwd[15]; //root password.
/* char *table_file[]={
"gsxx",
"bcxx",
"fgxx",
"hmbxx",
"ltxx",
NULL
};*/
//char *MySQL(和PHP搭配之最佳组合);
char mydatabase[256];
char MySQL(和PHP搭配之最佳组合)table[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(和PHP搭配之最佳组合) host:");scanf("%s",host);
printf("Root user:");scanf("%s",sid);
printf("Password:");scanf("%s",pwd);
printf("Loading........nn");
while(table_file[i]){
sprintf(mydatabase,"echo "create database %s"|MySQL(和PHP搭配之最佳组合) -h%s -u%s -p%s",table_file[i],host,sid,pwd);
sprintf(MySQL(和PHP搭配之最佳组合)table,"MySQL(和PHP搭配之最佳组合) -h%s -u%s -p%s %s<%s.sql",host,sid,pwd,table_file[i],table_file[i]);
db=system(mydatabase);
status=system(MySQL(和PHP搭配之最佳组合)table);
// printf("%sn%s",mydatabase,MySQL(和PHP搭配之最佳组合)table);
printf(table_file[i]);
//printf("%d",status);
if(db==0 && status==0){
printf("tttInstall [ OK ]n");
}else{
printf("tttInstall [ :( ]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 glad 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
};
些程序可以方便建表。。。有什么不明白与我联系。
程序随算不上什么。。。。。但也解决了一些批量建表的问提。
这个程序可以做为gcc刚入门爱好的参考,因为这个程序象hello world一样间简单。而且很全包括了指针,数组,文件包含,NULL
用户方法两个文件置于。/root/mygcc/下,将预建库MySQL(和PHP搭配之最佳组合)语句文件,文件名命名为xxxx.sql同上然后
#gcc my.c -o my
#my
即可。。。不用我在说了吧?
更多精彩
赞助商链接