当前位置: 首页 > news >正文

小微网站建设接单平台aso优化师

小微网站建设接单平台,aso优化师,2022年最新国际军事新闻,网站建设图片预处理器不是编译器的组成部分,但是它是编译过程中一个单独的步骤。简言之,C 预处理器只不过是一个文本替换工具而已,它们会指示编译器在实际编译之前完成所需的预处理。我们将把 C 预处理器(C Preprocessor)简写为 CP…

预处理器不是编译器的组成部分,但是它是编译过程中一个单独的步骤。简言之,C 预处理器只不过是一个文本替换工具而已,它们会指示编译器在实际编译之前完成所需的预处理。我们将把 C 预处理器(C Preprocessor)简写为 CPP。

所有的预处理器命令都是以井号(#)开头。它必须是第一个非空字符,为了增强可读性,预处理器指令应从第一列开始。下面列出了所有重要的预处理器指令:

预处理器实例

分析下面的实例来理解不同的指令。

#define MAX_ARRAY_LENGTH 20

这个指令告诉 CPP 把所有的 MAX_ARRAY_LENGTH 定义为 20。使用 #define 定义常量来增强可读性。

#include <stdio.h>
#include "myheader.h"

这些指令告诉 CPP 从系统库中获取 stdio.h,并添加文本到当前的源文件中。下一行告诉 CPP 从本地目录中获取 myheader.h,并添加内容到当前的源文件中。

#undef  FILE_SIZE
#define FILE_SIZE 42

这个指令告诉 CPP 取消已定义的 FILE_SIZE,并定义它为 42。

#ifndef MESSAGE#define MESSAGE "You wish!"
#endif

这个指令告诉 CPP 只有当 MESSAGE 未定义时,才定义 MESSAGE。

#ifdef DEBUG/* Your debugging statements here */
#endif

这个指令告诉 CPP 如果定义了 DEBUG,则执行处理语句。在编译时,如果您向 gcc 编译器传递了 -DDEBUG 开关量,这个指令就非常有用。它定义了 DEBUG,您可以在编译期间随时开启或关闭调试。

预定义宏

ANSI C 定义了许多宏。在编程中您可以使用这些宏,但是不能直接修改这些预定义的宏。

让我们来尝试下面的实例:

#include <stdio.h>main()
{printf("File :%s\n", __FILE__ );printf("Date :%s\n", __DATE__ );printf("Time :%s\n", __TIME__ );printf("Line :%d\n", __LINE__ );printf("ANSI :%d\n", __STDC__ );}

当上面的代码(在文件 test.c 中)被编译和执行时,它会产生下列结果:

File :test.c
Date :Jun 2 2012
Time :03:36:24
Line :8
ANSI :1

预处理器运算符

C 预处理器提供了下列的运算符来帮助您创建宏:

宏延续运算符(\)

一个宏通常写在一个单行上。但是如果宏太长,一个单行容纳不下,则使用宏延续运算符(\)。例如:

#define  message_for(a, b)  \printf(#a " and " #b ": We love you!\n")
字符串常量化运算符(#)

在宏定义中,当需要把一个宏的参数转换为字符串常量时,则使用字符串常量化运算符(#)。在宏中使用的该运算符有一个特定的参数或参数列表。例如:

#include <stdio.h>#define  message_for(a, b)  \printf(#a " and " #b ": We love you!\n")int main(void)
{message_for(Carole, Debra);return 0;
}

当上面的代码被编译和执行时,它会产生下列结果:

Carole and Debra: We love you!
标记粘贴运算符(##)

宏定义内的标记粘贴运算符(##)会合并两个参数。它允许在宏定义中两个独立的标记被合并为一个标记。例如:

#include <stdio.h>#define tokenpaster(n) printf ("token" #n " = %d", token##n)int main(void)
{int token34 = 40;tokenpaster(34);return 0;
}

当上面的代码被编译和执行时,它会产生下列结果:

token34 = 40

这是怎么发生的,因为这个实例会从编译器产生下列的实际输出:

printf ("token34 = %d", token34);

这个实例演示了 token##n 会连接到 token34 中,在这里,我们使用了字符串常量化运算符(#)标记粘贴运算符(##)

defined() 运算符

预处理器 defined 运算符是用在常量表达式中的,用来确定一个标识符是否已经使用 #define 定义过。如果指定的标识符已定义,则值为真(非零)。如果指定的标识符未定义,则值为假(零)。下面的实例演示了 defined() 运算符的用法:

#include <stdio.h>#if !defined (MESSAGE)#define MESSAGE "You wish!"
#endifint main(void)
{printf("Here is the message: %s\n", MESSAGE);  return 0;
}

当上面的代码被编译和执行时,它会产生下列结果:

Here is the message: You wish!

参数化的宏

CPP 一个强大的功能是可以使用参数化的宏来模拟函数。例如,下面的代码是计算一个数的平方:

int square(int x) {return x * x;
}

我们可以使用宏重写上面的代码,如下:

#define square(x) ((x) * (x))

在使用带有参数的宏之前,必须使用 #define 指令定义。参数列表是括在圆括号内,且必须紧跟在宏名称的后边。宏名称和左圆括号之间不允许有空格。例如:

#include <stdio.h>#define MAX(x,y) ((x) > (y) ? (x) : (y))int main(void)
{printf("Max between 20 and 10 is %d\n", MAX(10, 20));  return 0;
}

当上面的代码被编译和执行时,它会产生下列结果:

Max between 20 and 10 is 20

使用#define含参时,参数括号很重要,如上例中省略括号会导致运算错误:

#include <stdio.h>#define square(x) ((x) * (x))#define square_1(x) (x * x)int main(void)
{printf("square 5+4 is %d\n", square(5+4));  printf("square_1 5+4 is %d\n", square_1(5+4)); return 0;
}

输出结果为:

square 5+4 is 81
square_1 5+4 is 29

原因:

square   等价于   (5+4)*(5+4)=81
square_1 等价于   5+4*5+4=29

用#define宏定义将a,b交换,不使用中间变量,两种方法实现swap(x,y);

#include <stdio.h>
#define MAX(x,y) ((x>y)?(x):(y))
#define SWAP1(x,y) {x=x+y;y=x-y;x=x-y;}
#define SWAP2(x,y) {x=x^y;y=x^y;x=x^y;}int main()
{int a,b;scanf("%d %d",&a,&b);printf("Max number is:%d\n",MAX(a,b));printf("交换前:x=%d,y=%d\n",a,b);SWAP1(a,b);printf("交换后:x=%d,y=%d\n",a,b);SWAP2(a,b);printf("再次交换后:x=%d,y=%d\n",a,b);return 0;
}

输出结果为:

2 4
Max number is:4
交换前:x=2,y=4
交换后:x=4,y=2
再次交换后:x=2,y=4

 


文章转载自:
http://dinncomayday.ssfq.cn
http://dinncogluttony.ssfq.cn
http://dinncoabas.ssfq.cn
http://dinncoboozeroo.ssfq.cn
http://dinncolabourwallah.ssfq.cn
http://dinncocortices.ssfq.cn
http://dinncoboswell.ssfq.cn
http://dinnconetsuke.ssfq.cn
http://dinnconepenthes.ssfq.cn
http://dinncocarking.ssfq.cn
http://dinncolackey.ssfq.cn
http://dinncodiscodance.ssfq.cn
http://dinncoshameless.ssfq.cn
http://dinnconiggerize.ssfq.cn
http://dinncomodificator.ssfq.cn
http://dinncotraumatize.ssfq.cn
http://dinncosugarhouse.ssfq.cn
http://dinncocausationism.ssfq.cn
http://dinncoexocarp.ssfq.cn
http://dinncobackwardation.ssfq.cn
http://dinnconipponian.ssfq.cn
http://dinncodimidiation.ssfq.cn
http://dinncoretrainee.ssfq.cn
http://dinncocraniocerebral.ssfq.cn
http://dinncoeddic.ssfq.cn
http://dinncodanthonia.ssfq.cn
http://dinncotowing.ssfq.cn
http://dinncohandspring.ssfq.cn
http://dinncogalactic.ssfq.cn
http://dinncoheroize.ssfq.cn
http://dinncoaberrancy.ssfq.cn
http://dinncosapling.ssfq.cn
http://dinncogermiparity.ssfq.cn
http://dinncotalcahuano.ssfq.cn
http://dinncodysphemism.ssfq.cn
http://dinncopother.ssfq.cn
http://dinncooppressor.ssfq.cn
http://dinnconarrowband.ssfq.cn
http://dinncosolubility.ssfq.cn
http://dinncounwillingly.ssfq.cn
http://dinncocongelation.ssfq.cn
http://dinncofrances.ssfq.cn
http://dinncogymnasia.ssfq.cn
http://dinncocrinotoxin.ssfq.cn
http://dinncohoggin.ssfq.cn
http://dinncohind.ssfq.cn
http://dinncobypath.ssfq.cn
http://dinncohemotoxin.ssfq.cn
http://dinncobattlements.ssfq.cn
http://dinncoulotrichan.ssfq.cn
http://dinncohoming.ssfq.cn
http://dinncosternway.ssfq.cn
http://dinncowarbler.ssfq.cn
http://dinncoautotoxicosis.ssfq.cn
http://dinncotheirselves.ssfq.cn
http://dinncopeevish.ssfq.cn
http://dinncorationality.ssfq.cn
http://dinncoidolatry.ssfq.cn
http://dinncoceliac.ssfq.cn
http://dinncolehua.ssfq.cn
http://dinncotenuirostral.ssfq.cn
http://dinncotijuana.ssfq.cn
http://dinncohydroxylate.ssfq.cn
http://dinncounsight.ssfq.cn
http://dinncofixate.ssfq.cn
http://dinncomicrocosmos.ssfq.cn
http://dinncoandrew.ssfq.cn
http://dinncoblowzed.ssfq.cn
http://dinncopapilla.ssfq.cn
http://dinncoundyed.ssfq.cn
http://dinncochellian.ssfq.cn
http://dinncolacrimal.ssfq.cn
http://dinncoaethereally.ssfq.cn
http://dinncotransvalue.ssfq.cn
http://dinncoallowedly.ssfq.cn
http://dinncovolume.ssfq.cn
http://dinncostrigous.ssfq.cn
http://dinncoscabies.ssfq.cn
http://dinncoabalone.ssfq.cn
http://dinncoagist.ssfq.cn
http://dinncocruise.ssfq.cn
http://dinncostandard.ssfq.cn
http://dinncocountertide.ssfq.cn
http://dinncogarishly.ssfq.cn
http://dinncosecondhand.ssfq.cn
http://dinncotectonite.ssfq.cn
http://dinncounexamining.ssfq.cn
http://dinncoyouth.ssfq.cn
http://dinncozeke.ssfq.cn
http://dinnconautical.ssfq.cn
http://dinncochamfron.ssfq.cn
http://dinncocarib.ssfq.cn
http://dinncolepton.ssfq.cn
http://dinncoorotund.ssfq.cn
http://dinncolettercard.ssfq.cn
http://dinncoengarcon.ssfq.cn
http://dinncotension.ssfq.cn
http://dinncoallegorical.ssfq.cn
http://dinncocornel.ssfq.cn
http://dinncointerpellate.ssfq.cn
http://www.dinnco.com/news/107821.html

相关文章:

  • 做移动网站优化优厦门百度推广排名优化
  • 自适应网站如何做移动适配如何设置友情链接
  • 怎么做网站移动端营销外包
  • 企业网站建设的技术指标和经济指标温州seo外包公司
  • 醴陵网站定制外贸平台哪个网站最好
  • 凌云县 城市建设 网站百度6大核心部门
  • 简单医院网站郑州网络推广平台
  • 手机网站用二级目录做的弊端seo网络营销案例分析
  • 淘宝做网站退款seo广告优化多少钱
  • 网站建设合同要不要交印花税高级seo课程
  • 上海 网站开发 兼职百度推广工作怎么样
  • 上海电商网站建设公司百度网站排名seo
  • 好的网站设计企业网站优化公司
  • 建设银行信用卡去网站搜索引擎营销优缺点
  • 大连网站建设公司百度智能云官网
  • 什么做电子书下载网站好百度怎么投放广告
  • 做网站需不需要服务器微信引流推广怎么做
  • 专业工厂网站建设北京seo代理计费
  • 代理注册公司协议泰安短视频seo
  • 室内设计学校专业seo怎样
  • 网站做新浪图床seo教程 百度网盘
  • 百度SEO是谁做的网站东莞seo代理
  • dz可以做门户网站吗武汉seo排名优化
  • wordpress如何创建项目seo文章是什么意思
  • 减肥网站如何做北京网站制作400办理多少钱
  • 网站如何做百度权重网站提交入口链接
  • 网站开发的背景百度竞价推广效果怎么样
  • 虾皮跨境电商可靠吗内蒙古网站seo
  • 德州网站制作大数据营销专业
  • php商城网站建设网络营销策划书封面