"THE" Pointer

"the"

Page 1 of 1

2 Replies - 429 Views - Last Post: 20 February 2008 - 06:47 PM

#1 emotakoh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-October 07

"THE" Pointer

Posted 20 February 2008 - 06:43 PM

/*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. */

Is This A Good Question/Topic? 0
  • +

Replies To: "THE" Pointer

#2 axel  Icon User is offline

  • Bug Juice Doesn't Come in a Jar
  • member icon

Reputation: 2
  • View blog
  • Posts: 1,944
  • Joined: 31-December 06

Re: "THE" Pointer

Posted 20 February 2008 - 06:47 PM

¥ou are fired times three.
Was This Post Helpful? 0
  • +
  • -

#3 MarkoDaGeek  Icon User is offline

  • Dirty Technophile
  • member icon

Reputation: 13
  • View blog
  • Posts: 11,158
  • Joined: 13-October 01

Re: "THE" Pointer

Posted 20 February 2008 - 06:47 PM

*sigh*
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1