Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int indexCase = 1;
- if ( index == 0 ) { // Word on top edge
- strcpy( nearest[0], wordLines[index] );
- strcpy( nearest[1], wordLines[index + 1] );
- actualLength--;
- indexCase = 0;
- } else if ( index == textSize - 1 ) { // Word on bottom edge
- strcpy( nearest[1], wordLines[index - 1] );
- strcpy( nearest[2], wordLines[index] );
- actualLength--;
- } else { // General case: word not on edge.
- strcpy( nearest[0], wordLines[index - 1] );
- strcpy( nearest[1], wordLines[index] );
- strcpy( nearest[2], wordLines[index + 1] );
- }
- // Now we check for that word.
- bool foundWord = false;
- for ( int i = 0; i < actualLength; i++ ) {
- if ( i == indexCase ) {
- if ( strstr( nearest[i], word ) != NULL ) { // checking bigger string.
- char *lineBackup = calloc( strlen( nearest[i] ), sizeof( char ) );
- strcpy( lineBackup, nearest[i] );
- char *token = strtok(nearest[i], " ");
- while ( token != NULL ) {
- if ( strstr( token, word ) != NULL ) { // Obama to public: We got 'im.
- foundWord = true;
- markMisspelled( token );
- int pos = token - nearest[i];
- printRemaining( lineBackup, pos, token );
- break;
- } else { // we got the wrong guy... er, word, so let's just print it.
- printf("%s ", token);
- }
- token = strtok( NULL, " " ); // seriously this threw me off so bad.
- }
- free( lineBackup );
- printf("\n");
- }
- } else {
- printf( "%s\n", nearest[i] );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement