Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: searching within strings [modified] Pin
Zac Howland26-Jul-06 10:17
Zac Howland26-Jul-06 10:17 
GeneralRe: searching within strings Pin
jon-8027-Jul-06 7:46
professionaljon-8027-Jul-06 7:46 
GeneralRe: searching within strings Pin
Zac Howland28-Jul-06 3:38
Zac Howland28-Jul-06 3:38 
GeneralRe: searching within strings Pin
jon-8028-Jul-06 8:08
professionaljon-8028-Jul-06 8:08 
GeneralRe: searching within strings Pin
Zac Howland28-Jul-06 9:05
Zac Howland28-Jul-06 9:05 
GeneralRe: searching within strings Pin
jon-8028-Jul-06 22:18
professionaljon-8028-Jul-06 22:18 
AnswerRe: searching within strings Pin
jon-8028-Jul-06 22:53
professionaljon-8028-Jul-06 22:53 
GeneralRe: searching within strings Pin
jon-802-Aug-06 10:07
professionaljon-802-Aug-06 10:07 
Hi again,

I'm not sure if I'm repeating myself (sorry), but, strToken is returning a bad value:
+ strToken 0xcccccccc <Bad Ptr> char *

Code:
unsigned int CSentenceAr::search(const char *strWord)
{
// initialize local variables
unsigned long iWordCount = 0;
char buffer[MAX_WORD_LENGTH] = {0};
/* Algorithm:

strToken shall initially contain the sentence string.
When strWord is found from the string, this is removed
from the string so that this function checks the rest of the
string for other instances of the word.
*/
char *strToken = 0;

for (int iCurrent = 0; iCurrent < Size; iCurrent++)
// copy to buffer, used as parameter for strstr.
{ memcpy(buffer, Sentences.strSentence[iCurrent], MAX_SENTENCE_LENGTH);
strToken = strstr(buffer,strWord);

while (strToken !=0 && *strToken != 0)
{
if (strlen(strToken) > 0)
{
iWordCount++;
strToken += strlen(strWord);
}
strToken = strstr(strToken, strWord);
}
}
return (int) iWordCount;
}



Jon
AnswerRe: searching within strings Pin
Zac Howland26-Jul-06 9:13
Zac Howland26-Jul-06 9:13 
QuestionHow to write to DataBase MS Access Pin
nahitan26-Jul-06 7:28
nahitan26-Jul-06 7:28 
AnswerRe: How to write to DataBase MS Access Pin
Hamid_RT26-Jul-06 7:36
Hamid_RT26-Jul-06 7:36 
GeneralRe: How to write to DataBase MS Access Pin
nahitan26-Jul-06 8:24
nahitan26-Jul-06 8:24 
QuestionRe: How to write to DataBase MS Access Pin
David Crow26-Jul-06 8:16
David Crow26-Jul-06 8:16 
AnswerRe: How to write to DataBase MS Access Pin
led mike26-Jul-06 8:41
led mike26-Jul-06 8:41 
QuestionWhy doesn't this work? Simple file I/O Pin
liuphil126-Jul-06 7:25
liuphil126-Jul-06 7:25 
AnswerRe: Why doesn't this work? Simple file I/O Pin
Zac Howland26-Jul-06 7:47
Zac Howland26-Jul-06 7:47 
GeneralRe: Why doesn't this work? Simple file I/O Pin
liuphil126-Jul-06 8:01
liuphil126-Jul-06 8:01 
GeneralRe: Why doesn't this work? Simple file I/O Pin
David Crow26-Jul-06 8:18
David Crow26-Jul-06 8:18 
GeneralRe: Why doesn't this work? Simple file I/O Pin
liuphil126-Jul-06 8:52
liuphil126-Jul-06 8:52 
GeneralRe: Why doesn't this work? Simple file I/O Pin
Zac Howland26-Jul-06 8:57
Zac Howland26-Jul-06 8:57 
GeneralRe: Why doesn't this work? Simple file I/O Pin
Zac Howland26-Jul-06 8:56
Zac Howland26-Jul-06 8:56 
Questionform Displaying Pin
ningthemcha26-Jul-06 6:46
ningthemcha26-Jul-06 6:46 
AnswerRe: form Displaying Pin
Chris Losinger26-Jul-06 7:04
professionalChris Losinger26-Jul-06 7:04 
AnswerRe: form Displaying Pin
David Crow26-Jul-06 7:06
David Crow26-Jul-06 7:06 
AnswerRe: form Displaying Pin
Zac Howland26-Jul-06 7:28
Zac Howland26-Jul-06 7:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.