zoukankan      html  css  js  c++  java
  • C 文件直接包含

    C 文件直接包含

    有一部分代码很大,在很多函数中重复,可以直接写在另外的一个文件中,引用时直接包含。
    co.cpp两个函数都 包含c1.cxx。

    点击(此处)折叠或打开

    1. ////// co.cpp
    2. #include <stdio.h>
    3. #include <stdlib.h>
    4. void f1(int i){
    5.     int a;
    6.     #include "c1.cxx"
    7.     a=i;
    8.     printf("[%d][%s][%s] a=%d ",__LINE__, __func__,__FILE__,a);
    9. }
    10. void f2(int i){
    11.     int a;
    12.     #include "c1.cxx"
    13.     a=i;
    14.     printf("[%d][%s][%s] a=%d ",__LINE__, __func__,__FILE__,a);
    15. }
    16.     int
    17. main ( int argc, char *argv[] )
    18. {
    19.     f1(1);
    20.     f1(2);
    21. }
    22. ////// c1.cxx
    23. a = 10;
    24. printf("[%d][%s][%s] a=%d ",__LINE__, __func__,__FILE__,a);

    输出

    点击(此处)折叠或打开

    1. [2][f1][c1.cxx] a=10
    2. [8][f1] a=1
    3. [2][f1][c1.cxx] a=10
    4. [8][f1] a=2
  • 相关阅读:
    Codeforces
    BZOJ
    BZOJ
    HDU
    Codeforces
    codeforces
    HDU-5441 Travel 离线-并查集
    codefoeces-1000E We Need More Bosses(tarjan+最长链)
    牛客网暑期ACM多校训练营(第五场)H-subseq 树状数组
    HDU-3533 Escape (BFS
  • 原文地址:https://www.cnblogs.com/timssd/p/4781166.html
Copyright © 2011-2022 走看看