내가 진주를 프로그램에서이 코드를 구현하고 난 그것이 정확해야한다고 생각하지만, 나에게이 실수 코드를 제공합니다질문
이#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
using std::qsort;
int charcmp(char*x,char *y){ return *x-*y;}
#define wordmax 100
int main(void){
char word[wordmax];
char sig[wordmax];
while(scanf("%s",word)!=EOF){
strcpy(sig,word);
qsort(sig,strlen(sig),sizeof(char),charcmp);
printf("%s %s\n",sig,word);
}
return 0;
}
실수 :
1>------ Build started: Project: anagrams, Configuration: Debug Win32 ------
1> anagrams.cpp
1>c:\users\david\documents\visual studio 2010\projects\anagrams\anagrams.cpp(11): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'
1>c:\users\david\documents\visual studio 2010\projects\anagrams\anagrams.cpp(13): error C2664: 'qsort' : cannot convert parameter 4 from 'int (__cdecl *)(char *,char *)' to 'int (__cdecl *)(const void *,const void *)'
1> None of the functions with this name in scope match the target type
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
내가 존을 생각을 벤틀리는 그러한 종류의 주제를 알고 있어야합니다. 그렇다면 왜 그런 종류의 실수가 있습니까?
int charcmp(const void* x, const void* y)
{
return *(const char*)x - *(const char*)y;
}
오류 메시지 :
"매개 변수 4를 'int (__cdecl *) (char *, char *)'에서 'int (__cdecl *) (const void *, const void *)'로 변환 할 수 없습니다. 당신은 그 주장에 대해 기대하고있는 가치의 유형을 보았습니까? – Gian