for example the sentence in the text file is "daniweb offers the best solutions for C++. the website is www.daniweb.com."

i have the user to search the word "daniweb".
by using ifstream to read word by word, this is part of my codes

ifstream file ("lines.txt");
string word;
bool found = true;

while(!file.eof())
{ file>>word;
char c = word[word.size()-1]; // to check for the last character in the string contain any punctation marks
if (c == '.' || c == '?' || c == '!')
{ if (found)
cout <<  sentence << endl;
}
}

for this instance, it was able to print out both sentence line by line.
but is there any way for me to check the second sentence for the '.' between the url given so that the second sentence will be printed out as "daniweb."

Thanks in advance!

well here is the algorithm ....

algorithm stringmatch( t[0-n-1] , p[0- m-1])

t = array of text 
p = array of pattern u wanna match
{
       for i ->0 to n-m do ,
             j->0
            while j<m and p[j] = t[i+j]
                    j <- j+1
                   if j = m  return i
      return -1
}

it will return the position from where the string matches the pattern.

rahul... I dont think i get what ur codes mean... is there a way to do it by using the above size_t() function to check for the beginning of the sentence ?

well firstly i apologize that , i didnt quite read ur problem well , since the title spoke for itself.

well i have an easier way to do it .
u get the string thats the text in an array (t in alog) and the patter u wanna match in another array ( p in algo) .
the alog will work something like this

N O B O D Y - N O T I C E D - H I M 
N O T              
  N O T
      N O T 
         N O T
            N O T 
               N  O T
                    N O T

WELL AT THIS POINT THE SUBSTRING IS EQUAL TO STRING AND U GET WAT U ASKED FOR.

k srry didnt see that ......... well dont worry u get the kudos for that.....
:P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.