int main()
{
int A[50]; int size,i;
cout<<"enter the size of the array: ";
cin>>size;
cout<<"Enter the "<<size<<" numbers to be sorted"<<endl;
for(i=0;i<size;i++)
{
cin>>A[i];
}
>g++ -Wall main.cpp -o main
main.cpp: In function 'void printSortedArray(int*, int)':
main.cpp:18:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for(i=0;i<size;i++);
^~~
main.cpp:19:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
{
^
Second thing: You have a semi-colon after your for loop line in printedSortedArray, making your loop not actually be a loop.
Third thing: You are not actually calling your swap function. You're calling std::swap(int&, int&), which is the standard library's swap function, which happened to be internally accessible within <iostream>. This only works by coincidence, and is one reason why "using namespace std;" can be a bad idea if you don't know what you're doing.
I would rename your swap function to something else or put it in its own namespace.
Or just get rid of your swap function and #include <algorithm> to properly access std::swap.
Probably not since it is not really the brace that is the problem, but that errant semicolon. This is why you fix errors from the top down, the first "error" is the key "error".