I can't post my full code, since i can't delete it and had people from my class taking my work on the last several projects.. not looking to get into trouble for posting full code, but i can post this segment.
Code:
int main(void){
int total_words = 1;
char textArray[400][21];
char uArray[400][21];
//missing code here.. not relevant to the part im working on.
total_words = get_words(textArray);
get_Uwords(total_words, textArray, uArray);
// more missing code
}
Code:
void get_Uwords(int total_words, char (*textArray)[21], char (*uArray)[21]){
int i, j, count = 1, g = 0;
printf("%d", total_words);
strcpy(uArray[0], textArray[0]);
for(i = 0; i < total_words; i++){
g = 0;
for(j = 0; j < count ; j++)
{
g = 0; // reset "seen" for new word
// if strings equal...
if(strcmp(uArray[j], textArray[i]) == 0)
{
g = 1;
// break - we don't want to add this word to uarray
break;
}
// this is outside of the 'j' loop so can only be executed once for each word now
if (g == 0)
{
strcpy(uArray[count], textArray[i]);
count++;
}
}
}
}
I didn't want to do bool's so I simply made a similar type int validator.