Why is the exception?

Hello.
All I know in that I get an exception. I don't know the reason.Here is my code snippet:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
   int iteration=0;
   stopWord = strtok(stpWords, "\n");


   int stopFirst;
   int stopLast;
   
    while (stopWord)
   {
          foundStop = &fishBuffer[0];  
            foundStop = strstr(fishBuffer, stopWord);


stopFirst = foundStop-&fishBuffer[0];;
                       
   while(foundStop && stopFirst< 3000)
   {
                    foundStop = strstr(foundStop, stopWord );
                    ++foundStop;
                   stopFirst = foundStop-&fishBuffer[0]-1;
                    stopLast = strlen(stopWord)+stopFirst;
                    if( (fishBuffer[stopFirst-1]<0x41 || fishBuffer[stopFirst-1]>0x7a) &&
                    (fishBuffer[stopLast]<0x41 || fishBuffer[stopLast]>0x7a) )
                     {   
                         for(int k=0;k<6;++k)
                            cout << foundStop[k-3];               
                        for(int j = stopFirst;j<stopLast;++j)
                          fishBuffer[j]=7;
                          cout << endl;
                         for(int k=0;k<6;++k)
                            cout << foundStop[k-3];
                            cout << endl;

++iteration;
                       }//end if
                       

//                    cout  <<foundStop << endl;;
                    
   }

         stopWord = strtok(0, "\n");
         cout << iteration << endl;
   }
   

If you run this from a debugger and reproduce the exception, the debugger will snap and tell you exactly which line of code the exception is occurring on.

If you know how to use a debugger (specifically the watch window), you'll also probably see why the exception is happening.


But let's start with just narrowing it down. Run this again, but through your IDE's debugger. Then let us know which line is the culprit.
Topic archived. No new replies allowed.