All pastes #63670 Raw Edit

Mine

public text v1 · immutable
#63670 ·published 2006-06-10 13:27 UTC
rendered paste body
#include <stdio.h>
#include <string.h>



int cnt = 0, i,lenC;
	
char message [] = "the cat sat on the mat the";
char checkword [] = "the";

int main (void)
{
 	char *word, *msg;
	lenC = strlen(message);
	msg = message;
	word = checkword;
	

	for (i=0;i<lenC;i++){ // pass each char to word
		
		//*temp++ = message[i];
			
		while ((*word++ - *msg++) == 0){
			cnt++;    // increment counter
		}
	}
	

	//printf("The word is: %s\n", word);
	//printf("the sentence is: %s\n", *message);
	printf("the word occurs %i times\n", cnt);

return 0;
}