Expected constructor, destructor, or type conversion before ‘(’ token

#include <iostream>

using namespace std;

void swap(int *a, int *b)
{
	int temp; 
	temp = *a;
	*a = *b;
	*b = temp;
}
	
 selectionSort(vector<int> &A) { 
    int i, j, min;
    int n=(int)A.size();
    for(i=0;i<n-1;i++){
        min=i;
        for(j=i+1;j<n;j++){
            if(A[min]>A[j])
            min=j;
        }
        swap(A[min],A[i]);
    }
    
}
    

int main()
{
   vector<int> A = {5, 2, 6, 7, 2, 1, 0, 3};  
    selectionSort(A[]);
    int n=(int)A.size();
    for(int i=0;i<n;i++){
        cout<< A[i]<<endl;
    }
    
    return 0;
}

I am trying to run selection sort algorithm but its showing the above mentioned error
error line is selectionSort(vector &A) {
Also what am i suppose to use before selectionSort(vector &A) , void or int?

what' the i in front of selectionSort

this sounds weird too

#include

@J-M-L , the missing include happens when people don't use code tags

@anon8380294
Please edit your post and embed the code in code tags. Select the code and next click < / >. After that, save the post.

Damned.... :unamused: :scream: :skull_and_crossbones: :skull_and_crossbones:

I made a mistake while copying

Done

this would likely work (on a non AVR architecture, so ESP32 etc)

#include <iostream>
#include <vector>
using namespace std;

void swap(int *a, int *b)
{
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

void selectionSort(vector<int> &A) {
  int i, j, min;
  int n = (int)A.size();
  for (i = 0; i < n - 1; i++) {
    min = i;
    for (j = i + 1; j < n; j++) {
      if (A[min] > A[j])
        min = j;
    }
    swap(&A[min], &A[i]);
  }
}


void setup() {
  Serial.begin(115200);
  vector<int> A = {5, 2, 6, 7, 2, 1, 0, 3};
  selectionSort(A);
  int n = (int)A.size();
  for (int i = 0; i < n; i++) {
    Serial.print(A[i]); Serial.write(' ');
  }
  Serial.println();
}

void loop() {}

@sterretje @J-M-L Problem solved, initially I forgot to include vector header file :sweat_smile:

That helps for sure to have it!
:smile: