| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1109 人关注过本帖
标题:C里面'/' 斜杠
只看楼主 加入收藏
cosdos
Rank: 9Rank: 9Rank: 9
来 自:ShangHai
等 级:蜘蛛侠
威 望:6
帖 子:2109
专家分:1385
注 册:2007-6-19
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:5 
C里面'/' 斜杠
/*
int function(char *s)
{
    char * p ="+-*/
";  // 被VS这样显示了。
    ......
}
*/





(回顾了c的转义字符序列没有'\/'这样的用的。)
搜索更多相关主题的帖子: function 
2009-10-19 19:57
apwh7550
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:41
专家分:106
注 册:2009-10-17
收藏
得分:5 
c里边/*……*/是不允许嵌套的吧
编译器把字符串里的*/当做注释的结束符了
2009-10-19 20:14
cosdos
Rank: 9Rank: 9Rank: 9
来 自:ShangHai
等 级:蜘蛛侠
威 望:6
帖 子:2109
专家分:1385
注 册:2007-6-19
收藏
得分:0 
完全符合C注释的格式,



我非常不情愿的把"+-*/"改为"+/-*",样子还行。

[ 本帖最后由 cosdos 于 2009-10-19 20:21 编辑 ]

—>〉Sun〈<—
2009-10-19 20:18
StarWing83
Rank: 8Rank: 8
来 自:仙女座大星云
等 级:贵宾
威 望:19
帖 子:3951
专家分:748
注 册:2007-11-16
收藏
得分:5 
这个处理方法是正确的…………

  6.4.9 Comments
1 Except within a character constant, a string literal, or a comment, the characters /*
  introduce a comment. The contents of such a comment are examined only to identify
  multibyte characters and to find the characters */ that terminate it.69)
2 Except within a character constant, a string literal, or a comment, the characters //
  introduce a comment that includes all multibyte characters up to, but not including, the
  next new-line character. The contents of such a comment are examined only to identify
  multibyte characters and to find the terminating new-line character.
  EXAMPLE
3
                                            
         "a//b"                          // four-character string literal
         #include "//e"                  // undefined behavior
         // */                           // comment, not syntax error
         f = g/**//h;                    // equivalent to f = g / h;
         //\                             // part of a two-line comment
         i();
         /\
         / j();                          // part of a two-line comment
         #define glue(x,y) x##y
         glue(/,/) k();                  // syntax error, not comment
         /*//*/ l();                     // equivalent to l();
         m = n//**/o
            + p;                         // equivalent to m = n + p;


[ 本帖最后由 StarWing83 于 2009-10-19 20:28 编辑 ]

专心编程………
飞燕算法初级群:3996098
我的Blog
2009-10-19 20:20
m456m654
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:3
帖 子:783
专家分:2806
注 册:2009-9-17
收藏
得分:0 
TC下电脑会识别出'/'的,吼吼
2009-10-19 20:21
StarWing83
Rank: 8Rank: 8
来 自:仙女座大星云
等 级:贵宾
威 望:19
帖 子:3951
专家分:748
注 册:2007-11-16
收藏
得分:10 
标准规定必须如此,因此TC是不符合标准的。

另外,遇到这种情况,我一般是:"+-*\/",这样就行了

专心编程………
飞燕算法初级群:3996098
我的Blog
2009-10-19 20:29
快速回复:C里面'/' 斜杠
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020600 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved