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
46
47
48
49
50
51
52
53
54
55
56
57
| /* STRTOK.C: In this program, a loop uses strtok
* to print all the tokens (separated by commas
* or blanks) in the string named "string".
*/
#include "stdafx.h"
#include <string.h>
#include <stdio.h>
#include <locale.h>
#include <windows.h>
char string[100]; //= "A блджадить string\tof ,,tokens\nand some more tokens махать копать паять дрыить ффефефеть";
char seps[] = " ,\t\n";
char *c[] = {"ить", "ать", "ять", "еть"};
char buf[4];
char *no ="не ";
char temp[32];
char *token;
char *recent[100];
void main( void )
{
//
setlocale (LC_ALL,"russian");
printf("введите строку");
scanf("%s",string);
printf( "%s\n\nTokens:\n", string );
/* Establish string and get the first token: */
token = strtok( string, seps );
int i = 0;
while( token != NULL )
{
/* While there are tokens in "string" */
recent[i] = token;
/* Get next token: */
token = strtok( NULL, seps);
i++;
}
for(int j=0; j<i;j++){
memset(temp, 0, sizeof(temp));
buf[0] = recent[j][strlen(recent[j])-3];
buf[1] = recent[j][strlen(recent[j])-2];
buf[2] = recent[j][strlen(recent[j])-1];
for(int k = 0; k < sizeof(*c);k++){
if(strcoll(c[k],buf) == 0)
{
strcat(temp,no);
strcat(temp,recent[j]);
recent[j] = temp;
break;
}
}
printf( " %s", recent[j]);
}
getchar();
}
Проблема состоит в том что при вводе русских символов с клавиатуры не идёт их распознавание. |