啊!为什么编译器抱怨?谢谢你的帮助!
% gcc -o mine mine.c -lcrypt
mine.c: In function 'main':
mine.c:19:14: warning: assignment makes pointer from integer without a cast [enabled by default]
%
码:
#define _X_OPEN_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
const char key[] = "hello world";
const char salt[]="01";
const int MAXIMUM_HASH_LENGTH = 2 + 11;
int i=0;
char *hash;
long long hashes = 0L;
while (1) {
hash = crypt(key, salt); /* problem with this line... */
if (hash[2] == '0') {
int leading0s = 0;
leading0s++;
for (i=3; i < MAXIMUM_HASH_LENGTH; i++) {
if (hash[i] != '0') break;
leading0s++;
}
printf("Winner: %s has %d leading zeros.\n",
hash, leading0s);
printf("\t--> Hash %lld.\n\n", hashes);
}
if (hashes != 0 && (hashes % 10000) == 0) {
printf("Hash %d: %s\n", hashes, hash);
}
if (hashes== 1000000) break;
hashes++;
}
return 1000;
}
最佳答案
尝试将“#define _X_OPEN_SOURCE
”更改为“#define _XOPEN_SOURCE
”。