I am tring to compile this simple string array. I am getting some struct error. "Cannot pass object of non-POD type in line 63. which is "printf("%14d%10d\n",array[1], array[0]);"
please help
#include <stdlib.h>
#include <time.h>
#include <string>
#define row 15
#define col 2
using namespace std;
void PrintArray(char *Title, string array[row][col]);
void Shuffle(string m[row][col]);
int main(void)
{
string array[row][col] = {"the farmer drove to the city",
"the brakes were slipping",
"the road got very wet",
"water ran down the hill",
"potatoes spilled everywhere",
"she laid an egg",
"the feathers went flying",
"the duck went straight into the air",
"the dog ran quickly after it",
"everything was planted last spring",
"the farmers jumped in",
"april is a good time",
"rocks rolled everywhere",
"big bumps shook the cargo",
"the clock seems to tick faster"};;
/* initialize random generator */
srand( time(NULL));
/* fill the array with element # and random number */
for (int i=0; i<row; i++)
{
array[i][1] = rand();
}
PrintArray("Original Data",array);
Shuffle(array);
PrintArray("Shuffled Data",array);
return 0;
}
void PrintArray(char *Title, string array[row][col])
{
/* print the contents */
printf("\t%s\n",Title);
//printf("\tRandom\tElement\n");
printf("%14s%10s\n","Random","Element");
for (int i=0; i<row; i++)
{
printf("%14d%10d\n",array[i][1], array[i][0]);
}
/*add some white space*/
puts("\n\n");
}
void Shuffle(int a[row][col])
{
/* column 1 is random number, column 0 is element*/
int i,j,t;
/* the row for loop */
for (i=0; i < row-1; i++)
/* the column for loop */
for (j=0; j < row-i-1; j++)
if (a[j][1] > a[j+1][1])
{
t=a[j][1];
a[j][1]=a[j+1][1];
a[j+1][1]=t;
t=a[j][0];
a[j][0]=a[j+1][0];
a[j+1][0]=t;
}
}