hex和oct为什么是未定义标识符?
程序如下:#include <iostream>
void main()
{ char a[]="abcdefghijklmnopqrstuvwxyz";
int i;
for(i=0;i<25;i++)
{
std::cout<<"\'"<<a[i]<<"\'"
<<"="<<int(a[i])
<<"="<<oct(a[i])
<<"="<<hex(a[i]);
}
}
显示找不到标识符oct和hex。
#include <iostream> int main() { const char* str = "abcdefghijklmnopqrstuvwxyz"; const size_t len = strlen(str); for( size_t i=0; i<len; ++i ) { std::cout << '\'' << str[i] << '\'' << '=' << std::dec << int(str[i]) << '=' << std::oct << int(str[i]) << '=' << std::hex << int(str[i]) << '\n'; } return 0; }