selection sort on dynamic alloc array func needs primary express..

I wrote the same set of programs.. trying to see if they work on different obsolete compilers.. then now I am redoing this one just to see if I can do it from my head ... but when I try to use the void function... to sort the array without the help of vectors.. but dynamic alloc... this line is what's causing the error... I'm pretty sure I looked at it.. it gives primary expression before int and if I switch this line off the prog runs..

am I at least correct in saying that this is the line that's causing the error albeit I switched it off and it ran...

selectionSort(int *Integr_Val,Array_Size);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<iostream>
using namespace std;
void selectionSort(int*, int);
int *IntAlloc(int);

int main()
{
    int *Integr_Val;
    int Array_Size;
    cout<<"Type size:";
    cin>>Array_Size;
    
    Integr_Val=IntAlloc(Array_Size);
    
    if (Integr_Val==NULL)
    return 0;
    
    cout<<"Type the numbers below "<<endl;
     
    for (int count=0; count<Array_Size; count++)
    {
        cin>>*(Integr_Val+count);
     }
     
    selectionSort(int *Integr_Val,Array_Size);
    
    system("Pause");
    return 0;
    
}
    int *IntAlloc(int size)
    { 
    int *NuIntegr_Val;
    if (size<=0)
    return NULL;
    NuIntegr_Val=new int[size];
    return NuIntegr_Val;
     }
  void selectionSort(int *array1, int size)
  {
       int startScan, minIndex, minValue;
       for (startScan=0; startScan<(size-1); startScan++)
       { 
         minIndex =startScan;
         minValue=*(array1+startScan);
         for (int index=startScan+1; index<size; index++)
         {
             if ((*array1+index)<minValue)
             {
              minValue=*(array1+index);
              minIndex=index;
              }
              *(array1+minIndex)=*(array1+startScan);
              *(array1+startScan)=minValue;
         }
       }      
}
Last edited on
1
2
//selectionSort(int *Integr_Val,Array_Size);
selectionSort( Integr_Val, Array_Size ) ;
thanks hmmm.. I must need sleep.. but more eyes better than mine
thank you JlBorges!!
Topic archived. No new replies allowed.