Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 954823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:16:44+00:00 2026-05-16T00:16:44+00:00

i have implement this code from programming pearls and i think it should be

  • 0

i have implement this code from programming pearls and i think it should be correct but it gives me this mistake
code:

#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;
}

mistake:

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 ==========

i think jon bentley should know such kind of topic yes why is such kind of mistake?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:16:45+00:00Added an answer on May 16, 2026 at 12:16 am

    Your charcmp function needs to take const void* parameters:

    int charcmp(const void* x, const void* y)
    {   
        return *(const char*)x - *(const char*)y;
    }
    

    The error message:

    cannot convert parameter 4 from 'int (__cdecl *)(char *,char *)' to 'int (__cdecl *)(const void *,const void *)'

    is telling you that the argument you are passing (a pointer to the function charcmp) does not have the correct type to be passed into qsort.

    Since this question is tagged as C++, you might consider using std::sort instead; it is type safe and much easier to use:

    std::sort(sig, sig + strlen(sig));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using this code to implement a Popup JDialog of sorts, like
I want to implement this view But I have one question: The text which
I know this must be a n00b question, but I have to implement a
i have question from programming pearls problem is following show how to use Lomuto's
I have this piece of code: @Entity @Table(name = MOVERS) public class MOVers implements
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I have this code implemented and I like how straight forward it is because
I have BaseView which implement UIViewController. Every view in project must implement this BaseView.
I am trying to implement this demo on my local machine. http://bit.ly/4g4o1r I have
Thing is: I have a webcrawler framework, and independent modules that implement this framework.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.