Wheres my Code error? It says free() isnt correct and im getting segmentation fa
ID: 3657126 • Letter: W
Question
Wheres my Code error? It says free() isnt correct and im getting segmentation fault... Its in C NOT C++
#include<stdio.h>
void sort(int sorted[],int size);
int main()
{
int *arr;
int N,num,count;
printf("Enter how many integer you want to enter: ");
scanf("%d",&N);
int new[N];
int i;
for(i=0;i<N;i++)
{
printf("Enter integer %d: ", i+1);
scanf("%d",&arr[i]);
free(i);
}
sort(arr,N);
printf(" Number frequency");
for(i=0;i<N;)
{
count=1;
num=arr[i];
printf(" %d ",arr[i]);
while(arr[++i]==num){
count++;
}
printf("%d",count);
}
getchar();
return 0;
}
void sort(int sorted[],int size){
int i,j,temp;
for(i=0;i<size-2;i++)
{
for(j=0;j<size-1;j++)
{
if(sorted[j]<sorted[j+1]){
temp=sorted[j];
sorted[j]=sorted[j+1];
sorted[j+1]=temp;
}
}
}
return;
}
Explanation / Answer
PLease give the definition of the free() in the program.You dint do that
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.