【C++错误处理】VC6中关于bool __cdecl std::isdigit(_E,const class std::locale &)' : expects 2 arguments...

本文探讨了在使用VC6编译器时遇到的std::isdigit函数错误,并提供了有效的解决方案。通过调整代码中该函数的调用方式,避免了模板版本与标准C版本之间的冲突。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

作者:gnuhpc
出处:
http://www.cnblogs.com/gnuhpc/

今天在用VC6调试一个别人写的示例程序时,发现了这么一个错误:

 

bool __cdecl std::isdigit(_E,const class std::locale &)' : expects 2 arguments

 

出错的代码:

         

[cpp] view plaincopy

1.  return std::isdigit(_expr[_pos]) != 0; 

2.          bool (isdigit)(_E _C, const locale& _L) 

3.   

4.  while (_pos < _expr.length() && std::isdigit(_expr[_pos]) != 0) 

  

 

MSDN isdigit的定义如下:
template<class E>;
    bool isdigit(E c, const locale& loc) const;    

The template function returns use_facet< ctype<E>; >;(loc). is(ctype<E>;:: digit, c).

 

没有怎么看懂为什么MS把这么简单的一个函数定义的如此复杂...

 

后来看一个老外的解决方法:

you are using the std template version is isdigit which apparently requires two parameters. remove the std:: namespace and the compiler will use the standard C version that only requires one parmeter.

 

自然就解决了VC6标准模板和标准C之间的差别问题。

作者:gnuhpc
出处:
http://www.cnblogs.com/gnuhpc/

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值