什么是C或C#的使用? [英] What is The Use Of # in C or C++?

查看:174
本文介绍了什么是C或C#的使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道#在C或C ++使用.....请u能告诉我什么是排名的目的或为什么要使用它?

i would like to know the usage of # in C or C++..... please can u inform me what is the purpose of # or Why it is used?

推荐答案

在C / C ++中,标志,标志着preprocessor指令。

In C/C++, the # sign marks preprocessor directives.

如果你不熟悉的preprocessor,它会像编译过程的一部分,处理包括,宏等等。这实际上增加了code到最后的编译前的源文件。如果你正在使用gcc / g ++的,你可以看到在preprocessor生成使用 -E 标记。

If you're not familiar with the preprocessor, it works as part of the compilation process, handling includes, macros, and more. It actually adds code to the source file before the final compilation. If you're using gcc/g++, you can see what the preprocessor generates by using the -E flag.

包括:

#include <iostream>

包括用于包含文件的内容在指令的位置插入到当前文件。

Includes are used to insert the contents of the included file into the current file at the location of the directive.

的常量:

#define RANDOM_NUMBER 4

在处理过程中,该文件在 RANDOM_NUMBER 的每个实例会以文字与 4

During processing, every instance of RANDOM_NUMBER in the file will be textually replaced with 4

条件编译:

#ifdef DEBUG
printf( "Random number: %d", RANDOM_NUMBER );
#endif

在这种情况下,打印语句将只如果 DEBUG 宏被定义编译的程序的一部分。

In this case, the print statement will only be a part of the compiled program if the DEBUG macro has been defined.

这篇关于什么是C或C#的使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆