这篇文章主要介绍“怎么用gcc批量建mysql库表”,在日常操作中,相信很多人在怎么用gcc批量建mysql库表问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么用gcc批量建mysql库表”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
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(" ");
printf("MySQL host:");scanf("%s",host);
printf("Root user:");scanf("%s",sid);
printf("Password:");scanf("%s",pwd);
printf("Loading........ ");
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<%s.sql",host,sid,pwd,table_file[i],table_file[i]);
db=system(mydatabase);
status=system(mysqltable);
// printf("%s %s",mydatabase,mysqltable);
printf(table_file[i]);
//printf("%d",status);
if(db==0 && status==0){
printf(" Install [ OK ] ");
}else{
printf(" Install [ :( ] ");
}
i++;
}
address();
}
//------------------- Function ------------------
showme()
{
printf("------------------------------------------------------------------- ");
printf(" I am Netkiller Chen. ");
printf(" I am a programmer and system&net manager. ");
printf(" I am glad to be friend with you! ");
printf("------------------------------------------------------------------- ");
}
address()
{
printf(" ---------------------------------- ");
printf("| newtech@sina.com | ");
printf("| OICQ:13721218 | ");
printf("| 1/13/2001 | ");
printf("---------------------------------- ");
}
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语句文件,文件名命名为xxxx.sql同上然后
#gcc my.c -o my
#my
即可。。。
到此,关于“怎么用gcc批量建mysql库表”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!