cÖ¸ÕëÏê½â
µÚÒ»Õ ¸ÅÄî
Ö¸ÕëÊÇÒ»¸öÌØÊâµÄ±äÁ¿£¬ËüÀïÃæ´æ´¢µÄÊýÖµ±»½âÊͳÉΪÄÚ´æÀïµÄÒ»¸öµØÖ·¡£Òª¸ãÇåÒ»¸öÖ¸ÕëÐèÒª¸ãÇåÖ¸ÕëµÄËÄ·½ÃæµÄÄÚÈÝ£ºÖ¸ÕëµÄÀàÐÍ£¬Ö¸ÕëËùÖ¸ÏòµÄÀàÐÍ£¬Ö¸ÕëµÄÖµ»òÕß½ÐÖ¸ÕëËùÖ¸ÏòµÄÄÚ´æÇø£¬»¹ÓÐÖ¸Õë±¾ÉíËùÕ¼¾ÝµÄÄÚ´æÇø¡£ÈÃÎÒÃÇ·Ö±ð˵Ã÷¡£
ÏÈÉùÃ÷¼¸¸öÖ¸Õë·Å×Å×öÀý×Ó£º
ÀýÒ»£º
(1)int *ptr;
(2)char *ptr;
(3)int **ptr;
(4)int (*ptr)[3];
(5)int *(*ptr)[4];
Èç¹û¿´²»¶®ºó¼¸¸öÀý×ӵĻ°£¬Çë²ÎÔÄÎÒÇ°¶Îʱ¼äÌù³öµÄÎÄÕ < <ÈçºÎÀí½âcºÍc
++µÄ¸´ÔÓÀàÐÍÉùÃ÷>>¡£
¡¡
1 Ö¸ÕëµÄÀàÐÍ¡£
´ÓÓï·¨µÄ½Ç¶È¿´£¬ÄãÖ»Òª°ÑÖ¸ÕëÉùÃ÷Óï¾äÀïµÄÖ¸ÕëÃû×ÖÈ¥µô£¬Ê£ÏµIJ¿·Ö¾ÍÊÇÕâ¸öÖ¸ÕëµÄÀàÐÍ¡£ÕâÊÇÖ¸Õë±¾ÉíËù¾ßÓеÄÀàÐÍ¡£ÈÃÎÒÃÇ¿´¿´ÀýÒ»Öи÷¸öÖ¸ÕëµÄÀàÐÍ£º
(1)int *ptr; //Ö¸ÕëµÄÀàÐÍÊÇint *
(2)char *ptr; //Ö¸ÕëµÄÀàÐÍÊÇchar *
(3)int **ptr; //Ö¸ÕëµÄÀàÐÍÊÇ int **
(4)int (*ptr)[3]; //Ö¸ÕëµÄÀàÐÍÊÇ int(*)[3]
(5)int *(*ptr)[4]; //Ö¸ÕëµÄÀàÐÍÊÇ int *(*)[4]
ÔõôÑù£¿ÕÒ³öÖ¸ÕëµÄÀàÐ͵ķ½·¨ÊDz»ÊǺܼòµ¥£¿
¡¡
2 Ö¸ÕëËùÖ¸ÏòµÄÀàÐÍ¡£
µ±Äãͨ¹ýÖ¸ÕëÀ´·ÃÎÊÖ¸ÕëËùÖ¸ÏòµÄÄÚ´æÇøʱ£¬Ö¸ÕëËùÖ¸ÏòµÄÀàÐ;ö¶¨Á˱àÒëÆ÷½«°ÑÄÇƬÄÚ´æÇøÀïµÄÄÚÈݵ±×öʲôÀ´¿´´ý¡£
´ÓÓï·¨ÉÏ¿´£¬ÄãÖ»Ðë°ÑÖ¸ÕëÉùÃ÷Óï¾äÖеÄÖ¸ÕëÃû×ÖºÍÃû×Ö×ó±ßµÄÖ¸ÕëÉùÃ÷·û*È¥µô£¬Ê£ÏµľÍÊÇÖ¸ÕëËùÖ¸ÏòµÄÀàÐÍ¡£ÀýÈ磺
(1)int *ptr; //Ö¸ÕëËùÖ¸ÏòµÄÀàÐÍÊÇint
(2)char *ptr; //Ö¸ÕëËùÖ¸ÏòµÄµÄÀàÐÍÊÇchar
(3)int **ptr; //Ö¸ÕëËùÖ¸ÏòµÄµÄÀàÐÍÊÇ int *
(4)int (*ptr)[3]; //Ö¸ÕëËùÖ¸ÏòµÄµÄÀàÐÍÊÇ int()[3]
(5)int *(*ptr)[4]; //Ö¸ÕëËùÖ¸ÏòµÄµÄÀàÐÍÊÇ int *()[4]
ÔÚÖ¸ÕëµÄËãÊõÔËËãÖУ¬Ö¸ÕëËùÖ¸ÏòµÄÀàÐÍÓкܴóµÄ×÷Óá£
Ö¸ÕëµÄÀàÐÍ(¼´Ö¸Õë±¾ÉíµÄÀàÐÍ)ºÍÖ¸ÕëËùÖ¸ÏòµÄÀàÐÍÊÇÁ½¸ö¸ÅÄî¡£µ±Äã¶ÔCÔ½À´Ô½ÊìϤʱ£¬Äã»á·¢ÏÖ£¬°ÑÓëÖ¸Õë½ÁºÍÔÚÒ»ÆðµÄ“ÀàÐÍ”Õâ¸ö¸ÅÄî·Ö³É“Ö¸ÕëµÄÀàÐÍ”ºÍ“Ö¸ÕëËùÖ¸ÏòµÄÀàÐÍ”Á½¸ö¸ÅÄÊǾ«Í¨Ö¸ÕëµÄ¹Ø¼üµãÖ®Ò»¡£ÎÒ¿´Á˲»ÉÙÊ飬·¢ÏÖÓÐЩдµÃ²îµÄÊéÖУ¬¾Í°ÑÖ¸ÕëµÄÕâÁ½¸ö¸ÅÄî½ÁÔÚÒ»ÆðÁË£¬ËùÒÔ¿´ÆðÊéÀ´Ç°ºóì¶Ü£¬Ô½¿´Ô½ºýÍ¿¡£
3 Ö¸ÕëµÄÖµ£¬»òÕß½ÐÖ¸ÕëËùÖ¸ÏòµÄÄÚ´æÇø»òµØÖ·¡£
Ö¸ÕëµÄÖµÊÇÖ¸Õë±¾Éí´æ´¢µÄÊýÖµ£¬Õâ¸öÖµ½«±»±àÒëÆ÷µ±×÷Ò»¸öµØÖ·£¬¶ø²»ÊÇÒ»¸öÒ»°ãµÄÊýÖµ¡£ÔÚ32λ³ÌÐòÀËùÓÐÀàÐ͵ÄÖ¸ÕëµÄÖµ¶¼ÊÇÒ»¸ö32λÕûÊý£¬ÒòΪ32λ³ÌÐòÀïÄÚ´æµØÖ·È«¶¼ÊÇ32볤¡£
Ö¸ÕëËùÖ¸ÏòµÄÄÚ´æÇø¾ÍÊÇ´ÓÖ¸Õë
Ïà¹ØÎĵµ£º
1.1= Óë ==
Àý1£º
±¾ÀýÖÐÑ»·Óï¾äµÄ±¾ÒâÊÇÌø¹ýÎļþÖеĿոñ·û¡¢ÖƱí·û¡¢»»Ðзû
while(c=''||c=='\t'||c=='\n')
c=getc(f);
c= ''||c=='\t'||c=='\n'
ËÀÑ»·
Àý2£º
if((filedesc==open(argv[i],0))<0)
error();
ÓÀÔ¶²»»á±»µ÷ÓÃ
1.2 & ºÍ | ²»Í¬ÓÚ&& ºÍ||
1.3 CÓ ......
#include <stdio.h>
int main()
{
char *str[] = {"welcome", "to", "fortemedia", "nanjing"};
char **p = str + 1;
str[0] = ( *p++ ) + 2;
str[1] = * ( p + 1 );
str[2] = p[1] + 3;
str[3] = p[0] + ( str[2] - str[1] );
printf ( "%s\n", str[0] );
printf ( ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. setmemº¯Êý
setmemº¯ÊýµÄ¹¦ÄÜÊÇ´æÖµµ½´æ´¢Çø£¬ÆäÓ÷¨Îª£ºvoid setmem(void *addr, int len, char value);³ÌÐòʵÀýÈçÏ£º
#include <stdio.h& ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. setwritemodeº¯Êý
setwritemodeº¯ÊýµÄ¹¦ÄÜÊÇÉèÖÃͼÐη½Ê½Ï»ÏßµÄÊä³öģʽ£¬ÆäÓ÷¨Îª£ºvoid far setwritemode(int mode);³ÌÐòʵÀýÈçÏ£º
#include < ......
½ñÌìÍê³ÉÁËǶÈëʽlinuxµÄµÚÒ»¸öÇý¶¯µÄ±àдºÍ²âÊÔ£¬ËäÈ»ÊǸö¼òµ¥µÄ³ÌÐò£¬µ«ÊÇÂéȸËäС£¬ÎåÔà¾ãÈ«£¬Ï£Íû¿ÉÒÔ¸ø¸Õ¿ªÊ¼½Ó´¥Çý¶¯±àдµÄÈËһЩÌáʾ£¬¹²Í¬½ø²½¡£
Ô´´úÂ룺
·ÖÎöÈçÏ£º
ÏÂÃæÊÇÎÒµÄÇý¶¯³ÌÐò£º
#include <linux/config.h>//ÅäÖÃÍ·Îļþ
#include <linux/kernel.h&g ......