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 934975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:05:10+00:00 2026-05-15T21:05:10+00:00

#include <algorithm> #include <stdio.h> #include <iostream> int intcomp(int *x,int *y) { return *x-*y;}; int

  • 0
#include <algorithm>
#include <stdio.h>
#include <iostream>



int intcomp(int *x,int *y) {  return *x-*y;};
int a[10000];
int main(void){
    int i; int n=0;
     while (scanf("%d",&a[n])!=EOF)
          n++;
     qsort(a,n,sizeof(int),intcomp);
      for (int i=0;i<n;i++)
           printf("%d\n",a[i]);
       return 0;


}

it is just copy of code i have two question it show me that intcomp is incompatible in this code
and also what does intcomp function?
and also what is in windows 7 EOF? how tell program that it reached EOF?

  • 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-15T21:05:10+00:00Added an answer on May 15, 2026 at 9:05 pm

    First of all: the question is labeled C++ and you #include <algorithm> and <iostream>, but your code is 100% C.

    Martin York already gave the answer how to correct the signature of the function you pass to qsort().

    However, the “true”(TM) C++ solution would be to use std::sort<> instead of qsort!

    #include <algorithm>    
    #include <stdio.h>    
    
    bool intcomp(int a, int b) { return a<b; }
    int a[10000];    
    int main(void){    
        int n=0;    
         while (scanf("%d",&a[n])!=EOF)    
              n++;    
         std::sort(&a[0], &a[n], intcomp);
          for (int i=0;i<n;i++)    
               printf("%d\n",a[i]);    
           return 0;    
    }
    

    Note that incomp() takes ints and not int pointers, and returns a bool. Just like operator<() would.

    Also note that in this case, you could forget the intcomp and just use std::sort(&a[0], &a[n]), which will use std::less<>, which will use operator<(int, int).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main(void) {
for example there is code #include <algorithm> #include <stdio.h> #include <iostream> int intcomp(int *x,int
#include <iostream> #include <algorithm> #include <vector> #include <boost/array.hpp> #include <boost/bind.hpp> int main() { boost::array<int,
#include<stdio.h> #include<stdlib.h> char* re() { char *p = hello; return p; } int main()
#include <iostream> #include <tuple> int main(){ auto bt=std::make_tuple(std::tuple<>(),std::tuple<std::tuple<>>()); //Line 1 auto bt2=std::make_tuple(std::tuple<>(),std::tuple<>()); //Line 2
#include <iostream> using namespace std; int main() { int a, b, c, max; cout<<a=;
I have the following code #include <algorithm> #include <iostream> #include <vector> #include <functional> int
The code: #include stdafx.h #include stdio.h #include math.h #include stdlib.h #include time.h int main()
Consider the following code: #include <cstdlib> #include <iostream> #include <string> #include <vector> #include <algorithm>
here is code #include <iostream> #include <string> #include <algorithm> #include <vector> #include <fstream> #include

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.