linux c ¶ÁÈ¡ÎļþÐÐÊý
linux c ¶ÁÈ¡ÎļþÐÐÊý²ÎÕÕwc ϵͳÃüÁî±àдµÄº¯ÊýÈçÏ£º
#include <fcntl.h>
#include <stdlib.h>
#define MAXBSIZE 65536
u_long file_wc(char *file)
{
register u_char *p;
register short gotsp;
register int ch, len;
register u_long linect, charct;
int fd;
u_char buf[MAXBSIZE];
if (file) {
if ((fd = open(file, O_RDONLY, 0)) < 0)
return -1;
for (gotsp = 1; len = read(fd, buf, MAXBSIZE);) {
if (len == -1)
return -1;
charct += len;
for (p = buf; len--;) {
ch = *p++;
if (ch == '\n')
++linect;
if (isspace(ch))
gotsp = 1;
else if (gotsp) {
gotsp = 0;
}
}
}
}
return linect;
}
²âÊÔc
#include <stdlib.h>
int main(int argc,char *argv[])
{
u_long row;
row= file_wc("test.unl");
printf("%d\n",row);
return 0;
}
Ïà¹ØÎĵµ£º
1¡¢¶þ½øÖÆÎļþ£¨tar.gz£©°²×°
ÏÈ´´½¨Óû§ºÍÓû§×é
su - root
groupadd mysql
useradd -g mysql mysql
½âѹ¶þ½øÖÆÎļþ¡£
gunzip -c filename | tar -xf -
¸´ÖÆÄ¿Â¼/home/mysqlµ½/usr/local£»
´´½¨mysqlÐí¿É±í£º
linux:/usr/local/mysql #scripts/mysql_install_db --user=mysql
ÉèÖöþ½øÖÆËùÓÐȨ£¬Ê ......
1,freadÊÇ´ø»º³åµÄ,read²»´ø»º³å.
2,fopenÊDZê×¼cÀﶨÒåµÄ,openÊÇPOSIXÖж¨ÒåµÄ.
3,fread¿ÉÒÔ¶ÁÒ»¸ö½á¹¹.readÔÚlinux/unixÖжÁ¶þ½øÖÆÓëÆÕͨÎļþûÓÐÇø±ð.
4,fopen²»ÄÜÖ¸¶¨Òª´´½¨ÎļþµÄȨÏÞ.open¿ÉÒÔÖ¸¶¨È¨ÏÞ.
5,fopen·µ»ØÖ¸Õë,open·µ»ØÎļþÃèÊö·û(ÕûÊý).
6,linux/unixÖÐÈκÎÉ豸¶¼ÊÇÎļþ,¶¼¿ÉÒÔÓÃopen,read.
Èç¹ ......
(¼Ó#µÄÃüÁîΪ±ØÐëÔÚ¸ùÓû§È¨ÏÞϲÙ×÷)
Ò»¡¢¹Ø»úÓëÖØÐÂÆô¶¯
1£©#init 0ÖØÆô #init 6¹Ø»ú£¨¸Ä±äϵͳÔËÐм¶±ðµÄ·½·¨£©
2£©#rebootÖØÆô #halt¹Ø»ú£¨ÃüÁî·¨£©
3)#showdown -h +5 (5·ÖÖÓºó¹Ø»ú) #showdown -r +5(5·ÖÖÓºóÖØÆô)
¶þ¡¢³£ÓÃĿ¼²Ù×÷ÃüÁî
1£©ÏÔʾÎļþºÍĿ¼£ºls -a ......
µ¼¶Á£º
¡¡¡¡1£®Socket¼ò½é
¡¡¡¡SocketÊÇTCP/IPÍøÂçµÄAPI£¬¿ÉÒÔÓÃËüÀ´¿ª·¢ÍøÂçÓ¦ÓóÌÐò£¬SocketÊý¾Ý´«ÊäÊÇÒ»ÖÖÌØÊâµÄI/O£¬SocketÒ²ÊÇÒ»ÖÖÎļþÃèÊö·û
¡¡¡¡2£®SocketµÄ½¨Á¢
¡¡¡¡int socket(int domain£¬ int type£¬ int protocol)
¡¡¡¡º¯Êý·µ»Ø£ºÒ»¸öÕûÐ͵ÄSocketÃèÊö·û£¬¿ÉÒÔÔÚºóÃæµ÷ÓÃËü¡£
¡¡¡¡²ÎÊý˵Ã÷£º
¡¡¡ ......