Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void MyExit(void) { system("pause"); }

int main ()
{
  char *b = malloc(sizeof(char)*1000);
  char *filedata_2 = malloc(300);
  FILE *sp;
  char * pch = malloc(300);
  char alpha[] = "101";
  char beta[] = "100";
  char charlie[] = "001";
  int echo;
  int delta;
  int llamba;
  int one, *A;
  int two, *B;
  int three, *C;
  int total = 0;
  int tab = 0;

  atexit(MyExit);

  A = &one;
  B = &two;
  C = &three;
  *A = 0;
  *B = 0;
  *C = 0;
  sp = fopen("worklist_2.txt", "r");
  echo = atoi (alpha);
  delta = atoi (beta);
  llamba = atoi (charlie);
  if(!sp)
    {
    perror("Error: file worklist_2.txt was not found or opened");
    return 0;
    }

  printf("Input a short sentence: ");
  gets(b);

  pch = strtok (b," ,.-");
  while(pch != NULL)
    {
    while(fgets(filedata_2, 300, sp))
      {
      if(_memicmp(pch, filedata_2, strlen(pch)) == 0
            && (filedata_2[strlen(pch)] == ' '
            || filedata_2[strlen(pch)] == '\n'))
	  {
		  tab = 1;
		  break;	  		  
	  }
      else
        {
        strcpy(filedata_2, pch);
        strcat(filedata_2, " No match!\n");
        }
      }
	if(memchr (filedata_2, echo, strlen(filedata_2)))
		{
			  *A+= 1;
		}
	if(memchr (filedata_2, delta, strlen(filedata_2)))
		{
			 *B+= 1;
		}
	if(memchr (filedata_2, llamba, strlen(filedata_2)))
		{
			 *C+= 1;
		}


    printf("%s\n",filedata_2);
    rewind(sp);
    pch = strtok (NULL, " ,.-");
  }
  total = (one+two+three);
  printf("%d\n",total);
  return 0;
}
The text file
Code:
we 100

met 101

a 101

young 101

street 101

child 101

he 100

was 101

playing 101

what 101

looked 101

like 100

a 101

wooden 101

flute 100
The input string
Code:
We met a young street child, he was playing what looked like a wooden flute.
And the results:
Code:
Input a short sentence: We met a young street child, he was playing what looked
like a wooden flute.
we 100

met 101

a 101

young 101

street 101

child 101

he 100

was 101

playing 101

what 101

looked 101

like 100

a 101

wooden 101

flute 100
11
Press any key to continue . . .
There's 15 words and the program is only reporting 11 of them. I don't know why and I have been sitting here since this morning about 15 hours ago working on this. Can you help me fix this program?