Exemple #1
0
int main(int argc, char**argv) {
  char msg[SIZE];
  int len=0;
  // read in every line of the tweets
  // till there are no more lines
  while ((len=readMsg(msg)) != EOF) {
    msg[len]='\0';
    lowerStringCase(msg, len);
    // turn the string to lower case
    int wL=0;
    int prevEnd = 0;
    // get every word in the current line
    // until there are no more words
    do {
      //get length of the current word
      wL = wordLen(msg, len, prevEnd);
      // check the word against each keyword
      for(int i = 1; i < argc; i++) {
      matchAndEraseWord(msg,prevEnd,wL,argv[i]);
      }

    } while ((prevEnd = getNextWordIndex(msg,len,(prevEnd+wL))) != -1); 
    // output the processed message
  printf("%s", msg);
  }
  
  return 0;
}
void print1stWord(char *arr[], int length){
	char *tmp;
	for (int i = 0; i < length - 1; ++i)
	{
		for (int k = i + 1; k < length; k++)
		{
			if ((wordLen(arr[i])-wordLen(arr[k]))> 0){
				tmp = arr[i];
				arr[i] = arr[k];
				arr[k] = tmp;
			}
		}
	}

	for (int i = 0; i < length; i++)
	{
		puts(arr[i]);
	}
}