Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¹ØÓÚCÖеĻص÷º¯ÊýµÄÓ¦ÓÃ

ÔÚʹÓûص÷º¯ÊýÖУ¬ÍùÍù»áÉèÖÃÒ»¸öÖ¸Ïòº¯ÊýµÄÖ¸Õ룬ÄÇΪʲô²»Ö±½Ó½«º¯ÊýÃû×÷Ϊ²ÎÊý´«µÝÄØ£¿
Ô­ÒòÊÇ£ºÔÚCÓïÑÔÖк¯Êý±¾Éí²»ÊDZäÁ¿£¬µ«ÊÇ¿ÉÒÔ¶¨ÒåÖ¸Ïòº¯ÊýµÄÖ¸Õë¡£ÕâÖÖÀàÐ͵ÄÖ¸Õë¿ÉÒÔ±»¸³Öµ¡¢´æ·ÅÔÚÊý×éÖС¢´«µÝ¸øº¯ÊýÒÔ¼°×÷Ϊº¯ÊýµÄ·µ»ØÖµ£¬
ÏÂÃæÊÇÎÒÔÚÍøÉÏÕÒµ½µÄÒ»¸ö¹ØÓڻص÷º¯ÊýµÄСÀý×Ó£¨¶ÔÔ­ÎĵÄÀý×ÓÓÐËùÐ޸ģ©
Ô­ÎÄÁ´½Ó£ºhttp://hi.baidu.com/helloweenpad/blog/item/d96d13fb4b2276809f514607.html/cmtid/feb4928edf8883e5f11f3636
#include<stdio.h>
typedef int (*CallBackFun)(char *p);
/*¸ÃÓï¾ä¶¨ÒåÁËÀàÐÍCallBackFunÊÇ“Ò»¸öÖ¸Ïòº¯ÊýµÄÖ¸Õ룬¸Ãº¯Êý¾ßÓÐ1¸öchar *ÀàÐ͵IJÎÊý£¬·µ»ØÖµµÄÀàÐÍΪint.”*/
int Afun(char *p) {    // ·½·¨ Afun£¬¸ñʽ·ûºÏ CallBackFun µÄ¸ñʽ£¬Òò´Ë¿ÉÒÔ¿´×÷ÊÇÒ»¸ö CallBackFun
    printf("Afun »Øµ÷´òÓ¡³ö×Ö·û%s!\n", p);
    return 0;
}
int Cfun(char *p) {    // ·½·¨ Bfun£¬¸ñʽ·ûºÏ CallBackFun µÄ¸ñʽ£¬Òò´Ë¿ÉÒÔ¿´×÷ÊÇÒ»¸ö CallBackFun
    printf("Cfun »Øµ÷´òÓ¡:%s, Nice to meet you!\n", p);
    return 0;
}
int call(CallBackFun pCallBack, char *p) { // Ö´Ðлص÷º¯Êý£¬·½Ê½Ò»£ºÍ¨¹ýÃüÃû·½Ê½
    printf("call Ö±½Ó´òÓ¡³ö×Ö·û%s!\n", p);
    pCallBack(p);
    return 0;
}
int call2(char *p, int (*ptr)(char *p)) { // Ö´Ðлص÷º¯Êý£¬·½Ê½¶þ£ºÖ±½Óͨ¹ý·½·¨Ö¸Õë
    printf("==============\n", p);
    (*ptr)(p);
}
int call3(char *p, CallBackFun pCallBack){ // Ö´Ðлص÷º¯Êý£¬·½Ê½Ò»£ºÍ¨¹ýÃüÃû·½Ê½
    printf("--------------\n", p);
    pCallBack(p);
}
int main() { 
 
    char *p = "hello";
    call(Afun, p);
    call(Cfun, p);
    call2(p, Afun);
    call2(p, Cfun);
    call3(p, Afun);
    call3(p, Cfun);
    return 0;
}
ÔÚÔ­ÎÄÖУ¬×÷Õß½«int call2(char *p, int (*ptr)(char *p))»»³ÉÁËi


Ïà¹ØÎĵµ£º

ÎÒµÄCʵ¼ù(9)£ºÎ»ºÍ×Ö½ÚµÄÖØÅÅ

  λºÍ×Ö½ÚµÄÖØÅÅÔÚÃÜÂëѧËã·¨ÖÐÓй㷺µÄÓ¦Óá£
/* rearran.c£ºÎ»ºÍ×Ö½ÚµÄÖØÅÅ */
/* λ·´×ª£ºÒÔ×ÖµÄÖÐÐÄΪ¶Ô³Æµã½øÐÐλ·´Éä
ÀýÈ磺 abcd efgh ijkl mnop ABCD EFGH IJKL MNOP
λ·´×ª£ºPONM LKJI HGFE DCBA ponm lkji hgfe dcba */
unsigned rev(unsigned x){
/* ½»»»ÏàÁڵĵ¥¸öλ */
x=(x & 0x5 ......

C×Ö·û´®·´×ªËã·¨

Ò»¸öºÜ¼ò½àµÄËã·¨£º
void Reverse(char s[])
{
    for(int i = 0, j = strlen(s) - 1; i < j; ++i, --j) {
        char c = s[i];
        s[i] = s[j];
        s[j] = c;
 & ......

¡¾C\C++ÓïÑÔÈëÃÅƪ¡¿ Îļþ²Ù×÷(תÌû)

×î½üʵÔÚÊÇ̫æÁË£¬ÕâƪÕûÕû¾ÍÍƳÙÁË1¸öÔÂÁË£¬ÊµÔÚÊǶԲ»Æð¡£Ö®Ç°±¾´òËãÕâ¸öÄ£¿é¾Í½áÊøÁË£¬Îļþ²Ù×÷¾Í²»Ð´ÁË£¬µ«ÊÇÎļþ²Ù×÷ÓÖÊÇÒ»¸öºÜÖØÒªµÄ¶«Î÷£¬¶øÇÒÒ²¸ÕºÃÄܹ»×ܽá֮ǰÎÒÃÇѧϰµÄËùÓÐ֪ʶ¡£Í¬Ê±Ò²ÎªÁ˽«Îļþ²Ù×÷Õâ¸ö³õѧÕßÈÏΪºÜÉñÃصĶ«Î÷¸ø±¾ÖÊ»¯¡£Òò´Ë£¬±¾Æª½«ÖðÒ»½éÉÜCÓïÑÔµÄÎļþ²Ù×÷¡££¨±¾Ä£¿éµÄÃüÃû±¾À´ÊÇÏëC\C++Ò ......

ÔÚCºÍC£«£«Öаѱê×¼Êä³öÖض¨Ïòµ½Ö¸¶¨Îļþ

C++µÄʵÏÖ
#include<fstream>  
#include <iostream>
using namespace std;
int main()
{  
 ofstream logTest("foo.log");    
 streambuf *oldbuf = cout.rdbuf(logTest.rdbuf());   
  
 cout << "Êä³ö ......

Fortran & C »ì±à

C µ÷ÓÃ Fortran
c2ffn.f
      SUBROUTINE NAMEAGE(NAME, NLEN, AGE, TEMP)
      CHARACTER*(*) NAME
      INTEGER NLEN,AGE
      REAL TEMP
C
      WRITE(6,1000) NAME(1:NLEN),AGE,TEMP ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ