[英]Code blocks issues
嗨,我正在做一段課程,並且我在收到錯誤消息時遇到困難,它們是:
error 'strtoul' was not declared in this scope
error 'print' was not declared in this scope
error 'printf' was not declared in this scope
我輸入的代碼是:
using namespace std;
int main (int argc, const char * argv[]) {
unsigned long int a, tmp;
a = strtoul("01011111000110001001001011010011",ULL,2);
print(a);
//We always work on "a" pattern
print(tmp = a >> 4);
print(tmp = a << 6);
print(tmp = a & (long int) 0x3);
print(tmp = a & (char) 0x3);
print(tmp = a | (unsigned short) 0xf00f);
print(tmp = a ^ (long int) 0xf0f0f0f0);
return 0;
}
//Function prints unsigned long integer in hexadecimal and binary notation
void print(unsigned long b)
{
int i, no_bits = 8 * sizeof(unsigned long);
char binary[no_bits];
//Print hexadecimal notation
printf("Hex: %X\n", b);
//Set up all 32 bits with 0
for (i = 0; i < no_bits; i++) binary[i] = 0;
//Count and save binary value
for (i = 0; b != 0; i++) {
binary[i] = b % 2;
b = b/2;
}
//Print binary notation
printf("Bin: ");
for (i = 0 ; i < no_bits; i++) {
if ((i % 4 == 0) && (i > 0)) printf(" ");
printf("%d", binary[(no_bits - 1) - i]);
}
printf("\n\n");
}
但是我不斷收到錯誤消息:
error 'strtoul' was not declared in this scope
error 'print' was not declared in this scope
error 'printf' was not declared in this scope
無論我嘗試什么,當我嘗試聲明它們時,我總是收到相同的錯誤消息,那里有任何幫助嗎?
非常感激,
本
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.