Cº¯ÊýÖ¸Õë×ܽá
±¾ÎĽöÏÞÓÚC£¬Ö÷Òª×Ô¼ºÀÏÍü¡£±ðµÄ·Ï»°ÉÙ˵¡£
1.Basic
Ê×ÏÈ¿¼ÂǺ¯ÊýÔÚº¯ÊýÌåÄڵĶ¨Ò壬ÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
int main()
{
int add(int,int);
int def(int, int);
printf("%d\n", add(1,3));
printf("%d\n", def(3,1));
return 0;
}
int add(int a, int b) { return a+b; }
int def(int a, int b) { return a-b; }
¶¨ÒåÒ»¸öº¯ÊýÖ¸Õ룺
ReturnValue (*fun_ptr)();
ÉÏÃæµÄ´úÂëÓú¯ÊýÖ¸ÕëµôÓÃÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
int main()
{
int add(int,int);
int def(int, int);
int (*p)();
p = add;
printf("%d\n", p(1,3));
p = def;
printf("%d\n", p(3,1));
return 0;
}
int add(int a, int b) { return a+b; }
int def(int a, int b) { return a-b; }
µ½´ËΪֹòËÆûÓÐʲôÓ㬲»¹ý¿ÉÒÔ¿¼ÂÇÒ»¸ö¸ü¼Ó¾ßÓÐÃÀ¸ÐµÄд·¨£¬ÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
typedef struct FuncPtrEle
{
int (*fun_ptr)();
int type_code;
} ptr_t;
int add(int,int);
int def(int, int);
int main()
{
int i = 0;
ptr_t ptr_array[2];
ptr_array[0].fun_ptr = add; //ÕâÁ½Ö¸Õ븳ֵµÄ¹ý³Ì¿ÉÒÔÈÎÒâ·¢»ÓÏëÏóÁ¦¡£
ptr_array[1].fun_ptr = def; //ÖÁÓÚ×÷Óã¬ÏëÏëÃæÏò¶ÔÏóÖеĶà̬°É....
for(i = 0; i < 2; i++)
{
printf("%d\n", ptr_array[i].fun_ptr(3,1));
}
return 0;
}
int add(int a, int b) { ret
Ïà¹ØÎĵµ£º
Ò»¡¢Ê²Ã´ÊÇc/sºÍb/s
ÒªÏë¶Ô“c/s”ºÍ“b/s”¼¼Êõ·¢Õ¹±ä»¯ÓÐËùÁ˽⣬Ê×ÏȱØÐë¸ãÇå³þÈý¸öÎÊÌâ¡£
µÚÒ»¡¢Ê²Ã´ÊÇc/s½á¹¹¡£
c/s£¨client/server£©½á¹¹£¬¼´´ó¼ÒÊìÖªµÄ¿Í»§»úºÍ·þÎñÆ÷½á¹¹¡£ËüÊÇÈí¼þϵͳÌåϵ½á¹¹£¬Í¨¹ýËü¿ÉÒÔ³ä·ÖÀûÓÃÁ½¶ËÓ²¼þ»·¾³µÄÓÅÊÆ£¬½«ÈÎÎñºÏÀí·ÖÅäµ½client¶ËºÍserver¶ËÀ´ÊµÏÖ£¬½µµÍÁ ......
http://www.devdiv.net/blog/space-14481-do-blog-id-458.html
ÒÔÏ·ÖÎö»ùÓÚ£º
Developer Platform :S60 3rd Edition, Feature Pack 2 SDK
Operating System :Symbian OS v9.3
Ò»£¬ÎªÊ²Ã´ÒªÊ¹ÓÃClient/Server¼Ü¹¹
ÔÚSymibian OSÖÐËùÓеÄÒì²½·þÎñ¶¼ÊÇServerͨ¹ýC/S¼Ü¹¹À´ÊµÏֵġ£ClientÊÇÀûÓÃServerÌṩµÄÌض¨· ......
clock()·µ»Øclock_tÀàÐÍ£»
ÔÚtime.hÍ·ÎļþÖУ¬¶¨ÒåÁË typedef long clock_t
clock()ÊÇÓÃÀ´¼ÆËãÁ½¸öʱ¼äµãÖ®¼äµÄʱ¼ä¼ä¸ô¡£ÈçϳÌÐò£º
#include <stdio.h>
int main()
{
int i = 0;
clock_t start_time, end_time;
start_time = clock(); //¿ªÊ¼¼Æʱ, start_time = 0
while( ......
ºÃ¾ÃûÉÏÀ´ÁË...Óеã¶Ô²»Æð×Ô¼ºµÄÁ¼ÐÄ...
»°ËµÕâ¶Îʱ¼ä¿ì¸øÕâ¸öº¯Êý¸ãËÀÁË...
ÎÒÕÒÕÒ...ÎÒÕÒÎÒÕÒ...ÎÒ¾ÍÊÇÒª°ÑËü¸ø¸ãÃ÷°×ÁË...
»°ËµÇ°¶Îʱ¼äÄǸöËÀÈËËÄÔòÔËËãÒ²°Ñ×Ô¼º¸ãµÃ°ëËÀÁË...¶î...ÏÖÔÚ»¹ÔÚÍ£¹¤×´Ì¬...ÔÎËÀ....
ÔÙ˵scanf(),ÉÏÍøÊÇ¿ÉÒÔÕÒµ½Ð©¶«Î÷....µ«ÊǶ¼²»ÔõôÃ÷°×...´òËã×Ô¼º¸ãÃ÷°×ÁËÔÙÉÏÀ´Ð´¸öÏêϸµãµÄ°É...
......
Ò»¸öÓÉC/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö
1¡¢Õ»Çø£¨stack£©— ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å
£¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
2¡¢¶ÑÇø£¨heap£© — Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å
£¬
Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ ¡£×¢ÒâËüÓëÊý¾Ý½á¹¹ÖеĶÑÊÇÁ½»ØÊ£¬·ÖÅä·½ ......