Why would this be crashing?
I am using this code:
Code:
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
//Global Variables
ifstream infile;
ofstream outfile;
typedef char string[30];
//Prototypes
void tocaps(string []);
void bubblesort(string [],string [], string [], int);
void cutoff(string []);
void dashinsert(string []);
int binarySearch(int list[],int size, int key);
void report();
int main()
{
string social[30],phone[30],name[30];
int i;
int numel=30;
infile.open("In599A.Dat");
while(!infile.eof())
{
for(i=0;i<23;i++)
{
infile>>social[i]>>phone[i];
infile.getline(name[i],30);
}
}
//Function calls
bubblesort(name,social,phone,numel);
return 0;
}
void bubblesort(string name[],string social[], string phone[], int numel)
{
int i, j;
string temp;
for(i=0;i<numel-1;i++)
for(j=1;j<numel;j++)
{
if(strcmp(name[j],name[j-1])>0)
{
strcpy(temp,name[j]);
strcpy(name[j],name[j-1]);
strcpy(name[j-1],temp);
strcpy(temp,social[j]);
strcpy(social[j],social[j-1]);
strcpy(social[j-1],temp);
strcpy(temp,phone[j]);
strcpy(phone[j],phone[j-1]);
strcpy(phone[j-1],temp);
}
}
}