아아! 컴파일러가 불평하는 이유는 무엇입니까? 어떤 도움을 주셔서 감사합니다!crypt() : 캐스트가없는 정수에 대한 포인터?
% 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;
}
당신은 적어도하지에'토굴()가'선언되지 않은 플랫폼에서이 컴파일하고 또한 코드의 라인 (34)을 수정해야 포함 된 헤더 파일. 하지만 실제로 컴파일러 경고 메시지를 Google에 전달하는 것이 어려울까요? –
나는 여기를 보았다 - http://www.gnu.org/software/libc/manual/html_node/crypt.html - 중요한 차이점을 발견 할 수 없었다. 맨 페이지에는 #define과 함께이 포함되어 있습니다. –
user1505713