我正在处理此代码,该代码允许用户输入可包含空格和连字符的名称。
#ifdef __NV_CL_C_VERSION
/**
* @def NVIDIA
* @brief defined when compiling on NVIDIA GPUs
*/
#define NVIDIA
#endif // __NV_CL_C_VERSION
#if defined(__WinterPark__) || defined(__BeaverCreek__) || defined(__Turks__) || \
defined(__Caicos__) || defined(__Tahiti__) || defined(__Pitcairn__) || \
defined(__Capeverde__) || defined(__Cayman__) || defined(__Barts__) || \
defined(__Cypress__) || defined(__Juniper__) || defined(__Redwood__) || \
defined(__Cedar__) || defined(__ATI_RV770__) || defined(__ATI_RV730__) || \
defined(__ATI_RV710__) || defined(__Loveland__) || defined(__GPU__) || \
defined(__Hawaii__)
#define AMD
/**
* @def AMD
* @brief defined when compiling on AMD GPUs
* @note This list was originally found at https://github.com/magnumripper/JohnTheRipper/wiki/Predefined-macros-in-OpenCL-(standard-and-proprietary) and copied shamelessly. It is most definitely incomplete and contains the troubling __GPU__.
* @note AMD also defines __CPU__ when compiling for CL_DEVICE_TYPE_CPU.
*/
#endif // ...
我遇到的问题是识别连字符并将其包含在结束首字母输出中的代码
答案 0 :(得分:0)
在你要检查空格的if语句中,还要检查连字符:
if(pUpper == ' ' || pUpper == '-')
编辑:
要在输出中包含连字符,请执行以下操作:
if(pUpper == ' ')
{
result = result + "." + cUpper;
}
else if(pUpper == '-')
{
result = result + "-" + cUpper;
}