当前位置:网站首页>Macro application connector\

Macro application connector\

2022-06-25 10:18:00 Large factory oriented programming

Connector \ That is, one line of code can be written on multiple lines , When using macros , Can improve the readability of the code

#include <stdio.h>


// When you define a macro , There can be spaces before the next line , however \ After that, it is better not to have blank space ,

#define swap(a,b)\ {
       \ int t=a;\ a=b; \ b=t;\ } \ 

// When defining a function macro, you must add {}, Or use do-while(0) Structure , Recommended do while form 
//#define  The directive can unload only one line , No use {}. It's all like this , To write to multiple lines , Must use \, Put everything together in one line 
// Although it may not be necessary \, But it's not readable 


int main()
{
    
  pri\
ntf("hello");//\ No space after , There should be no spaces before the next line i,
  // For consecutive words ( Function name , keyword , Variable time )
  
  int a=1,b=2,c=3;
  swap(a,b);

  
  return 0;
}
原网站

版权声明
本文为[Large factory oriented programming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250937006514.html