hi I have two syntax errors in this program and what its should print out is the array strings in alphabetical order from client and their business type. any feedback is appreciated.
Code:
#include <iostream>
#include <string>
using namespace std;
void bubbleSort(string[], int);
int main ()
{
string Client[12] = { "Acme Construction\t\tMachinery design", "Johnson Electrical\t\tSwitch manufacturing", "Brown Heating and Cooling\tBoiler design", "Jones Computers\t\t\tComputers sales",
"Williams Cleaning\t\tEquipment Machinery sales","Smith Switches\t\t\tSwitch manufacturing"};
cout << "Client\t\t\t\t"<< "Business type\n" << endl;
for (int i=0; i<12; i++)
cout << Client[i] << endl;
return 0;
}
void bubbleSort(string arr[], int n)
{
int i, j, flag=1;
int temp;
for(i = 0; (i <= n) && flag; i++)
{
flag =0;
for(j=0;j<(n-1); j++)
{
if ( arr[j+1] < arr[j])
{
temp = arr[i];
arr[j] = arr[j +1];
arr[j + 1] = temp;
flag = 1;
}
}
}
return 0;
}
Code:
1>------ Rebuild All started: Project: 2-d, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project '2-d', configuration 'Debug|Win32'
1>Compiling...
1>2-d.cpp
1>c:\users\martin\documents\visual studio 2008\projects\2-d\2-d\2-d.cpp(32) : error C2440: '=' : cannot convert from 'std::string' to 'int'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\users\martin\documents\visual studio 2008\projects\2-d\2-d\2-d.cpp(39) : error C2562: 'bubbleSort' : 'void' function returning a value
1> c:\users\martin\documents\visual studio 2008\projects\2-d\2-d\2-d.cpp(5) : see declaration of 'bubbleSort'
1>Build log was saved at "file://c:\Users\Martin\Documents\Visual Studio 2008\Projects\2-d\2-d\Debug\BuildLog.htm"
1>2-d - 2 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========