/*Write a program to find the number of times that a given word (i.e. a short string) occurs in a sentence(i.e. a long string)*/
/*These are my codes but something is wrong and I dont know what or why*/
#include<string.h>
#include<stdio.h>
char s1[50];
int x;
main()
{
clrscr();
gets (s1);
for(x=0;x<strlen(s1);x++)
if(s1[x]=="the")
printf("-");
else
printf("%c",s1[x]);
getch();
}
/*I want to write program that will read from the standard input. The first line is a single word which is followed by the general text on the second line. Read both up to a newline character, and insert a termintating null before proceeding*/
/*Typical output should be:*/
/*The word is "the",*/
/*The sentence is "the cat sat on the mat".*/
/*The word occurs 2 times. */
"THE" Pointer"the"
Page 1 of 1
2 Replies - 434 Views - Last Post: 20 February 2008 - 06:47 PM
Replies To: "THE" Pointer
Page 1 of 1