#include<stdlib.h>
#include<stdio.h>
#ifndef COMPARE_H
#define COMPARE_H
using namespace std;
int compare(const void* pfirst,const void *psecond);
#endif
int compare(const void* pfirst,const void *psecond)
{
const int first=*((const int *) pfirst);
const int second=*((const int *) psecond);
return(first-second);
}
void main()
{
int iarr[10]={9,83,100,1,645,-7654,4,23,543,9};
int j=0;
for(;j<10;j++)
printf("element %d of iarr is:%d\n",j,iarr[j]);
qsort(iarr,10,sizeof(int),compare);
printf("sorted\n\n");
j=0;
for(;j<10;j++)
printf("element %d of iarr is:%d\n",j,iarr[j]);
}
<< moderator edit: added [code][/code] tags >>
when i run this program,it states "std"does not exist or is not a namesapce.
then i delete "using namespace std" it's working!
why this happen?