符号(@)和美元符号($)在C或C ++中有任何特殊含义 [英] Does At symbol (@) and Dollar Sign ($) has any special meaning in C or C++

查看:2287
本文介绍了符号(@)和美元符号($)在C或C ++中有任何特殊含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我的一个朋友在面试中遇到了这个问题。面试官问他是否有特殊字符,如 $,@,|,^,〜在c或c ++和其中有任何用法。

Recently one of my friend encountered this question in an interview. The interviewer asked him if the special characters like $, @, |, ^, ~ have any usage in c or c++ and where.

我知道 |,^和〜分别用作按位OR,XOR和Complement。

I know that |, ^ and ~ are used as Bitwise OR, XOR and Complement respectively.

但我不知道 @和$ 是否有任何特殊意义。

But I don't know if @ and $ has any special meaning. If it does, could you please give example where it can be applied?

推荐答案

@ 一般在C中无效;它不用于任何东西。

@ is generally invalid in C; it is not used for anything. It is used for various purposes by Objective-C, but that's a whole other kettle of fish.

$ 是由Objective-C用于各种目的无效,但许多实现允许它出现在标识符,就像一封信。 (在这些实现中,例如,你可以命名一个变量或函数 $$$ 如果你喜欢。)即使在那里,它没有任何特殊的意义。

$ is invalid as well, but many implementations allow it to appear in identifiers, just like a letter. (In these implementations, for instance, you could name a variable or function $$$ if you liked.) Even there, though, it doesn't have any special meaning.

这篇关于符号(@)和美元符号($)在C或C ++中有任何特殊含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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