WORD COUNER C++

IM DOING A WORD COUNTER PROGRAM BUT HAVE A PROBLEM WITH THE "void sort_word"... PLEASE HELP ME IF YOU CAN... THANKS

#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;

char str [10000];
void sort_word();
void ctos();
int main ()
{

char words [1001][64];
int counter = 0;
char *token;
ifstream infile;
infile.open("input.txt");

if(!infile.is_open())
{
cout<<"input.txt does not exists"<<endl;
system("pause");
return 0;
}

ctos();
cout << str << endl;

for (int i= 0; i < 1001; i++)
strcpy(words[i], " ");


while (infile.getline(str,sizeof(str),'\n'))
{
token = strtok(str, " ");

while(token!= NULL)
{
strcpy(words[counter], token);
cout << words[counter] << endl;
counter++;

token = strtok(NULL, " ");
}
}
int count;
cout << "\t" << "*Word*" << "\t" << " *Frequency*" << "\n";
ofstream outfile;
outfile.open("output.txt");
cout << "\t" << "*Word*" << "\t" << " *Frequency*" << "\n";



for(int i=0;i<counter-1;i++)
for(int j=i+1;j<counter;j++)
if(strcmp(words[i],words[j])>0)
{
token=words[i];
strcpy (words[i],words[j]);
strcpy(words[j],token);
}


for(int i=0; i< counter; i++)
{
count = 1;

for(int j= i+1; j < counter; j++)
if(strcmp(words[i],words[j])==0)
{
count++;
strcpy(words[j], "");
}

if(strcmp(words[i], " ")!=0)
{
cout << "\t" << words[i] << "\t\t" << count << "\n";
outfile << "\t" << words[i] << "\t\t" << count << "\n";
}
}

outfile.close();

system ("PAUSE");
return 0;
}
void sort_word()
{
char temp[1001][64];

for (int i= 0; i < 1001; i++)
strcpy(temp," ");

for (int i= 0; i <1001; i++) // for words
{
for(int j= 0; j<1001; j++) // for temp
{
if(strcmp(temp[j], " "))
{
strcpy(temp[j],words[i]);
break;
}

}

}

}


void ctos()
{
int length = strlen(str);
int i;
for (i = 0; i < length; i++){
{
if (str[i] >= 'A' && str[i] <= 'Z')
{
str[i] = 32 + str[i];
}
if (str[i] <'a' || str[i] > 'z')
str[i] = ' ';
}
}
}
What is "a problem"? Be more explicit.
Topic archived. No new replies allowed.