随笔分类 - linux c
摘要:要进行linux下的mysql的C编程,需要安装mysql及mysql的开发包,ubuntu下直接apt-get install libmysql++安装开发包。#include <mysql.h>相关函数:MYSQL *mysql_init(MYSQL *);//这里称之为载入函数吧,返回的MYSQL指针要用到后续的函数中int mysql_options(MYSQL *connection, enum option_to_set,const char *argument);//设置MYSQL*的一些属性,比如超时时间等MYSQL *mysql_real_connect(MYSQ
阅读全文
摘要:#include <unistd.h>#include <stdio.h>#include <errno.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>const char *file="locktest";int main(void){ int file_res; file_res=open(file,O_RDWR|O_CREAT|O_EXCL,0444); if(file_res == -1) { printf(&quo
阅读全文
摘要:1 #include <sys/socket.h> 2 #include <sys/types.h> 3 #include <unistd.h> 4 #include <stdio.h> 5 #include <stdlib.h> 6 #include <string.h> 7 #include <netdb.h> 8 9 int main(int argc,char *argv[])10 {11 int tar_socket=socket(AF_INET,SOCK_STREAM,0);12 struct so
阅读全文
摘要:1 #include <stdio.h> 2 #include <unistd.h> 3 #include <netdb.h> 4 5 int main(int argc,char *argv[]) 6 { 7 struct servent serv; 8 struct servent *serv_info=&serv; 9 10 serv_info=getservbyport(htons(atoi(argv[1])),NULL);/*第二个参数为协议类型,为NULL时自动匹配所有协议*/11 printf("%s\n%d\n",
阅读全文
浙公网安备 33010602011771号